+void yf::HttpRewrite::Event::anyTagEnd(const char *tag, int tag_len,
+ int close_it)
+{
+ if (close_it)
+ {
+ if (!s_within.empty())
+ {
+ std::list<Within>::const_iterator it = s_within.top();
+ std::string t(tag, tag_len);
+ if (regex_match(t, it->tag))
+ s_within.pop();
+ }
+ }
+ if (close_it)
+ wrbuf_putc(m_w, '/');
+ wrbuf_putc(m_w, '>');
+}
+
+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 *sep)
+{
+ std::list<Within>::const_iterator it = m_content->within_list.begin();
+ bool subst = false;
+
+ for (; it != m_content->within_list.end(); it++)
+ {
+ std::string t(tag, tag_len);
+ if (it->tag.empty() || regex_match(t, it->tag))
+ {
+ std::string a(attr, attr_len);
+ if (!it->attr.empty() && regex_match(a, it->attr))
+ subst = true;
+ }
+ if (subst)
+ break;
+ }
+
+ wrbuf_putc(m_w, ' ');
+ wrbuf_write(m_w, attr, attr_len);
+ if (value)
+ {
+ wrbuf_puts(m_w, "=");
+ wrbuf_puts(m_w, sep);
+
+ std::string output;
+ if (subst)
+ {
+ std::string s(value, val_len);
+ it->exec(m_vars, s, true);
+ wrbuf_puts(m_w, s.c_str());
+ }
+ else
+ wrbuf_write(m_w, value, val_len);
+ wrbuf_puts(m_w, sep);
+ }
+}
+
+void yf::HttpRewrite::Event::closeTag(const char *tag, int tag_len)
+{
+ if (!s_within.empty())
+ {
+ std::list<Within>::const_iterator it = s_within.top();
+ std::string t(tag, tag_len);
+ if (regex_match(t, it->tag))
+ s_within.pop();
+ }
+ wrbuf_puts(m_w, "</");
+ wrbuf_write(m_w, tag, tag_len);
+}
+
+void yf::HttpRewrite::Event::text(const char *value, int len)
+{
+ std::list<Within>::const_iterator it = m_content->within_list.end();
+ if (!s_within.empty())
+ it = s_within.top();
+ if (it != m_content->within_list.end())
+ {
+ std::string s(value, len);
+ it->exec(m_vars, s, false);
+ wrbuf_puts(m_w, s.c_str());
+ }
+ else
+ wrbuf_write(m_w, value, len);
+}
+
+static bool embed_quoted_literal(
+ std::string &content,
+ std::map<std::string, std::string> &vars,
+ mp::filter::HttpRewrite::RulePtr ruleptr,
+ bool html_context)