+static bool embed_quoted_literal(
+ std::string &content,
+ std::map<std::string, std::string> &vars,
+ mp::filter::HttpRewrite::RulePtr ruleptr)
+{
+ bool replace = false;
+ std::string res;
+ const char *cp = content.c_str();
+ const char *cp0 = cp;
+ while (*cp)
+ {
+ if (*cp == '"' || *cp == '\'')
+ {
+ int m = *cp;
+ cp++;
+ res.append(cp0, cp - cp0);
+ cp0 = cp;
+ while (*cp)
+ {
+ if (cp[-1] != '\\' && *cp == m)
+ 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[1] == '/')
+ {
+ while (cp[1] && cp[1] != '\n')
+ cp++;
+ }
+ cp++;
+ }
+ res.append(cp0, cp - cp0);
+ content = res;
+ return replace;
+}
+
+bool yf::HttpRewrite::Within::exec(
+ std::map<std::string, std::string> & vars,
+ std::string & txt, bool anchor) const
+{
+ if (type == "quoted-literal")
+ {
+ return embed_quoted_literal(txt, vars, rule);
+ }
+ else
+ {
+ return rule->test_patterns(vars, txt, anchor);
+ }
+}
+