From 13d8b45b1e703049ed2903adcf67a09dd9226557 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 5 Jul 2013 15:43:52 +0200 Subject: [PATCH] Using regex for comparing tags --- src/filter_http_rewrite.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/filter_http_rewrite.cpp b/src/filter_http_rewrite.cpp index 5fa1e63..855ee95 100644 --- a/src/filter_http_rewrite.cpp +++ b/src/filter_http_rewrite.cpp @@ -61,7 +61,7 @@ namespace metaproxy_1 { public: std::string header; std::string attr; - std::string tag; + boost::regex tag; std::string type; bool reqline; RulePtr rule; @@ -309,8 +309,7 @@ void yf::HttpRewrite::Event::openTagStart(const char *tag, int tag_len) std::list::const_iterator it = m_content->within_list.begin(); for (; it != m_content->within_list.end(); it++) { - if (it->tag.length() > 0 && yaz_strcasecmp(it->tag.c_str(), - t.c_str()) == 0) + if (!it->tag.empty() && regex_match(t, it->tag)) { std::vector attr; boost::split(attr, it->attr, boost::is_any_of(",")); @@ -336,7 +335,7 @@ void yf::HttpRewrite::Event::anyTagEnd(const char *tag, int tag_len, { std::list::const_iterator it = s_within.top(); std::string t(tag, tag_len); - if (yaz_strcasecmp(it->tag.c_str(), t.c_str()) == 0) + if (regex_match(t, it->tag)) s_within.pop(); } } @@ -356,8 +355,7 @@ void yf::HttpRewrite::Event::attribute(const char *tag, int tag_len, for (; it != m_content->within_list.end(); it++) { std::string t(tag, tag_len); - if (it->tag.length() == 0 || - yaz_strcasecmp(it->tag.c_str(), t.c_str()) == 0) + if (it->tag.empty() || regex_match(t, it->tag)) { std::string a(attr, attr_len); std::vector attr; @@ -400,7 +398,7 @@ void yf::HttpRewrite::Event::closeTag(const char *tag, int tag_len) { std::list::const_iterator it = s_within.top(); std::string t(tag, tag_len); - if (yaz_strcasecmp(it->tag.c_str(), t.c_str()) == 0) + if (regex_match(t, it->tag)) s_within.pop(); } wrbuf_puts(m_w, " 0) + w.tag = values[2]; std::map::const_iterator it = rules.find(values[3]); if (it == rules.end()) -- 1.7.10.4