static bool embed_quoted_literal(
std::string &content,
std::map<std::string, std::string> &vars,
- mp::filter::HttpRewrite::RulePtr ruleptr)
+ mp::filter::HttpRewrite::RulePtr ruleptr,
+ bool html_context)
{
bool replace = false;
std::string res;
const char *cp0 = cp;
while (*cp)
{
- if (*cp == '"' || *cp == '\'')
+ if (html_context && !strncmp(cp, """, 6))
+ {
+ cp += 6;
+ res.append(cp0, cp - cp0);
+ cp0 = cp;
+ while (*cp)
+ {
+ if (!strncmp(cp, """, 6))
+ break;
+ if (*cp == '\n')
+ break;
+ cp++;
+ }
+ if (!*cp)
+ break;
+ std::string s(cp0, cp - cp0);
+ if (ruleptr->test_patterns(vars, s, true))
+ replace = true;
+ cp0 = cp;
+ res.append(s);
+ }
+ else if (*cp == '"' || *cp == '\'')
{
int m = *cp;
cp++;
{
if (type == "quoted-literal")
{
- return embed_quoted_literal(txt, vars, rule);
+ return embed_quoted_literal(txt, vars, rule, true);
}
else
{
{
std::list<Within>::const_iterator it = within_list.begin();
if (it != within_list.end())
- embed_quoted_literal(content, vars, it->rule);
+ embed_quoted_literal(content, vars, it->rule, false);
}
void yf::HttpRewrite::Content::configure(
" <within tag=\"script\" attr=\"#text\" type=\"quoted-literal\" rule=\"url\"/>\n"
" <within tag=\"style\" attr=\"#text\" rule=\"url\"/>\n"
" <within attr=\"href,src\" rule=\"url\"/>\n"
+ " <within attr=\"onclick\" type=\"quoted-literal\" rule=\"url\"/>\n"
" </content>\n"
" <content type=\"quoted-literal\" mime=\".*javascript\">\n"
" <within rule=\"url\"/>\n"
" Another abs link</a>"
"<a href=\"/docs/page4.html\" />"
"<a href=\"cxcx\" />"
- "<a href=\"cx \" />"
+ "<a href=\"cx \" onclick=\"foo("foo");\"/>"
"</body></html>";
const char *resp_expected =
"HTTP/1.1 200 OK\r\n"
- "Content-Length: 573\r\n"
+ "Content-Length: 605\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"
" Another abs link</a>"
"<a href=\"/docs/page4.html\"/>"
"<a href=\"cycx\"/>"
- "<a href=\"cy \"/>"
+ "<a href=\"cy \" onclick=\"foo("bar");\"/>"
"</body></html>";
Z_GDU *gdu_res;