From: Adam Dickmeiss Date: Thu, 27 Jun 2013 09:50:23 +0000 (+0200) Subject: Only do CDATA for attr="#text", verbose flag X-Git-Tag: v1.3.59~40 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=41ddc790e888e2b0cfe5da66a34e26e737e20b54;p=metaproxy-moved-to-github.git Only do CDATA for attr="#text", verbose flag --- diff --git a/src/filter_http_rewrite.cpp b/src/filter_http_rewrite.cpp index e69aba6..90e3152 100644 --- a/src/filter_http_rewrite.cpp +++ b/src/filter_http_rewrite.cpp @@ -68,7 +68,9 @@ namespace metaproxy_1 { class HttpRewrite::Phase { public: + Phase(); std::list within_list; + int m_verbose; void rewrite_reqline(mp::odr & o, Z_HTTP_Request *hreq, std::map & vars) const; void rewrite_headers(mp::odr & o, Z_HTTP_Header *headers, @@ -225,6 +227,9 @@ void yf::HttpRewrite::Phase::rewrite_body(mp::odr & o, HTMLParser parser; Event ev(this, vars); + + parser.set_verbose(m_verbose); + std::string buf(*content_buf, *content_len); parser.parse(ev, buf.c_str()); @@ -265,7 +270,17 @@ void yf::HttpRewrite::Event::openTagStart(const char *tag, int tag_len) if (it->tag.length() > 0 && yaz_strcasecmp(it->tag.c_str(), t.c_str()) == 0) { - enabled_within = it; + std::vector attr; + boost::split(attr, it->attr, boost::is_any_of(",")); + size_t i; + for (i = 0; i < attr.size(); i++) + { + if (attr[i].compare("#text") == 0) + { + enabled_within = it; + break; + } + } } } } @@ -560,9 +575,19 @@ std::string yf::HttpRewrite::Replace::sub_vars ( return out; } +yf::HttpRewrite::Phase::Phase() : m_verbose(0) +{ +} void yf::HttpRewrite::configure_phase(const xmlNode *ptr, Phase &phase) { + static const char *names[2] = { "verbose", 0 }; + std::string values[1]; + values[0] = "0"; + mp::xml::parse_attr(ptr, names, values); + + phase.m_verbose = atoi(values[0].c_str()); + std::map rules; for (ptr = ptr->children; ptr; ptr = ptr->next) { diff --git a/src/test_filter_rewrite.cpp b/src/test_filter_rewrite.cpp index 65cb4c0..2e4ae54 100644 --- a/src/test_filter_rewrite.cpp +++ b/src/test_filter_rewrite.cpp @@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE( test_filter_rewrite_1 ) "\n" "\n" - " \n" + " \n" " \n" " \n" " \n" " \n" " \n" - " \n" - " \n" + " \n" + " \n" + " \n" " \n" " \n" "\n"