as argument, so that quoting (if any) is preserved.
void anyTagEnd(const char *tag, int tag_len, int close_it);
void attribute(const char *tag, int tag_len,
const char *attr, int attr_len,
- const char *value, int val_len);
+ const char *value, int val_len,
+ const char *sep);
void closeTag(const char *tag, int tag_len);
void text(const char *value, int len);
const Phase *m_phase;
void yf::HttpRewrite::Event::attribute(const char *tag, int tag_len,
const char *attr, int attr_len,
- const char *value, int val_len)
+ const char *value, int val_len,
+ const char *sep)
{
std::list<Within>::const_iterator it = m_phase->within_list.begin();
bool subst = false;
wrbuf_putc(m_w, ' ');
wrbuf_write(m_w, attr, attr_len);
- wrbuf_puts(m_w, "=\"");
+ wrbuf_puts(m_w, "=");
+ wrbuf_puts(m_w, sep);
std::string output;
if (subst)
wrbuf_write(m_w, value, val_len);
else
wrbuf_puts(m_w, output.c_str());
- wrbuf_puts(m_w, "\"");
+ wrbuf_puts(m_w, sep);
}
void yf::HttpRewrite::Event::closeTag(const char *tag, int tag_len)
const char *cp);
int skipAttribute(HTMLParserEvent &event,
const char *cp, int *attr_len,
- const char **value, int *val_len);
+ const char **value, int *val_len, int *tr);
Rep();
~Rep();
int m_verbose;
int mp::HTMLParser::Rep::skipAttribute(HTMLParserEvent &event,
const char *cp, int *attr_len,
- const char **value, int *val_len)
+ const char **value, int *val_len,
+ int *tr)
{
int i = skipName(cp);
*attr_len = i;
i += skipSpace(cp + i);
if (cp[i] == '\"' || cp[i] == '\'')
{
- char tr = cp[i];
+ *tr = cp[i];
v0 = ++i;
- while (cp[i] != tr && cp[i])
+ while (cp[i] != *tr && cp[i])
i++;
v1 = i;
if (cp[i])
}
else
{
+ *tr = 0;
v0 = i;
while (cp[i] && !strchr(SPACECHR ">", cp[i]))
i++;
int attr_len;
const char *value;
int val_len;
- int nor = skipAttribute(event, cp+i, &attr_len, &value, &val_len);
+ int tr;
+ int nor = skipAttribute(event, cp+i, &attr_len, &value, &val_len, &tr);
i += nor;
if (nor)
{
+ char x[2];
+ x[0] = tr;
+ x[1] = 0;
if (m_verbose)
printf ("------ attr %.*s=%.*s\n", attr_len, attr_name,
val_len, value);
- event.attribute(name, len, attr_name, attr_len, value, val_len);
+ event.attribute(name, len, attr_name, attr_len, value, val_len, x);
}
else
{
int close_it) = 0;
virtual void attribute(const char *tag, int tag_len,
const char *attr, int attr_len,
- const char *value, int val_len) = 0;
+ const char *value, int val_len,
+ const char *sep) = 0;
virtual void closeTag(const char *tag, int tag_len) = 0;
virtual void text(const char *value, int len) = 0;
};
const char *resp_expected =
"HTTP/1.1 200 OK\r\n"
- "Content-Length: 522\r\n"
+ "Content-Length: 520\r\n"
"Content-Type: text/html\r\n"
"Link: <http://proxyhost/proxypath/targetsite/file.xml>; rel=absolute\r\n"
"Link: </dir/file.xml>; rel=relative\r\n"
"xified"
"<a href=\"http://proxyhost/proxypath/targetsite/page2.html\">"
" An absolute link</a>"
- "<a target=\"_blank\" href=\"http://proxyhost/proxypath/targetsite/page3.html\">"
+ "<a target=_blank href=\"http://proxyhost/proxypath/targetsite/page3.html\">"
" Another abs link</a>"
"<a href=\"/docs/page4.html\"/>"
"</body></html>";
void openTagStart(const char *tag, int tag_len) {
out += "<";
out.append(tag, tag_len);
- }
-
+ }
+
void attribute(const char *tag, int tag_len,
const char *attr, int attr_len,
- const char *value, int val_len) {
+ const char *value, int val_len, const char *sep) {
out += " ";
out.append(attr, attr_len);
- out += "=\"";
+ out += "=";
+ out += sep;
out.append(value, val_len);
- out += "\"";
+ out += sep;
}
void anyTagEnd(const char *tag, int tag_len, int close_it) {
if (close_it)
"<html><body><a t1=v1 t2='v2' t3=\"v3\">some text</a>"
"<hr><table ></table ><a href=\"x\"/></body></html>";
const char* expected =
- "<html><body><a t1=\"v1\" t2=\"v2\" t3=\"v3\">some text</a>"
+ "<html><body><a t1=v1 t2='v2' t3=\"v3\">some text</a>"
"<hr><table></table ><a href=\"x\"/></body></html>";
MyEvent e;
hp.set_verbose(1);
std::cout << e.out << std::endl;
BOOST_CHECK_EQUAL(std::string(expected), e.out);
}
- catch (std::exception & e)
+ catch (std::exception & e)
{
std::cout << e.what();
std::cout << std::endl;