+void yf::HttpRewrite::Content::quoted_literal(
+ std::string &content,
+ std::map<std::string, std::string> &vars) const
+{
+ 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::list<Within>::const_iterator it = within_list.begin();
+ std::string s(cp0, cp - cp0);
+ if (it != within_list.end())
+ it->rule->test_patterns(vars, s, 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;
+}
+
+void yf::HttpRewrite::Content::configure(
+ const xmlNode *ptr, std::map<std::string, RulePtr > &rules)
+{
+ for (; ptr; ptr = ptr->next)
+ {
+ if (ptr->type != XML_ELEMENT_NODE)
+ continue;
+ if (!strcmp((const char *) ptr->name, "within"))
+ {
+ static const char *names[6] =
+ { "header", "attr", "tag", "rule", "reqline", 0 };
+ std::string values[5];
+ mp::xml::parse_attr(ptr, names, values);
+ Within w;
+ w.header = values[0];
+ w.attr = values[1];
+ w.tag = values[2];
+ std::map<std::string,RulePtr>::const_iterator it =
+ rules.find(values[3]);
+ if (it == rules.end())
+ throw mp::filter::FilterException
+ ("Reference to non-existing rule '" + values[3] +
+ "' in http_rewrite filter");
+ w.rule = it->second;
+ w.reqline = values[4] == "1";
+ within_list.push_back(w);
+ }
+ }
+}
+