projects
/
metaproxy-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
a58c13a
)
Using regex for comparing tags
author
Adam Dickmeiss
<adam@indexdata.dk>
Fri, 5 Jul 2013 13:43:52 +0000
(15:43 +0200)
committer
Adam Dickmeiss
<adam@indexdata.dk>
Fri, 5 Jul 2013 13:43:52 +0000
(15:43 +0200)
src/filter_http_rewrite.cpp
patch
|
blob
|
history
diff --git
a/src/filter_http_rewrite.cpp
b/src/filter_http_rewrite.cpp
index
5fa1e63
..
855ee95
100644
(file)
--- 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;
public:
std::string header;
std::string attr;
- std::string tag;
+ boost::regex tag;
std::string type;
bool reqline;
RulePtr rule;
std::string type;
bool reqline;
RulePtr rule;
@@
-309,8
+309,7
@@
void yf::HttpRewrite::Event::openTagStart(const char *tag, int tag_len)
std::list<Within>::const_iterator it = m_content->within_list.begin();
for (; it != m_content->within_list.end(); it++)
{
std::list<Within>::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<std::string> attr;
boost::split(attr, it->attr, boost::is_any_of(","));
{
std::vector<std::string> 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<Within>::const_iterator it = s_within.top();
std::string t(tag, tag_len);
{
std::list<Within>::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();
}
}
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);
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<std::string> attr;
{
std::string a(attr, attr_len);
std::vector<std::string> attr;
@@
-400,7
+398,7
@@
void yf::HttpRewrite::Event::closeTag(const char *tag, int tag_len)
{
std::list<Within>::const_iterator it = s_within.top();
std::string t(tag, tag_len);
{
std::list<Within>::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, "</");
s_within.pop();
}
wrbuf_puts(m_w, "</");
@@
-726,7
+724,8
@@
void yf::HttpRewrite::Content::configure(
Within w;
w.header = values[0];
w.attr = values[1];
Within w;
w.header = values[0];
w.attr = values[1];
- w.tag = values[2];
+ if (values[2].length() > 0)
+ w.tag = values[2];
std::map<std::string,RulePtr>::const_iterator it =
rules.find(values[3]);
if (it == rules.end())
std::map<std::string,RulePtr>::const_iterator it =
rules.find(values[3]);
if (it == rules.end())