metaproxy  1.13.0
Classes | Namespaces | Functions | Variables
filter_http_rewrite.cpp File Reference
#include "config.hpp"
#include <metaproxy/filter.hpp>
#include <metaproxy/package.hpp>
#include <metaproxy/util.hpp>
#include "filter_http_rewrite.hpp"
#include "html_parser.hpp"
#include <yaz/zgdu.h>
#include <yaz/log.h>
#include <stack>
#include <boost/regex.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <map>
Include dependency graph for filter_http_rewrite.cpp:

Go to the source code of this file.

Classes

class  metaproxy_1::filter::HttpRewrite::Replace
 
class  metaproxy_1::filter::HttpRewrite::Rule
 
class  metaproxy_1::filter::HttpRewrite::Within
 
class  metaproxy_1::filter::HttpRewrite::Content
 
class  metaproxy_1::filter::HttpRewrite::Phase
 
class  metaproxy_1::filter::HttpRewrite::Event
 

Namespaces

 metaproxy_1
 
 metaproxy_1::filter
 

Functions

static bool embed_quoted_literal (std::string &content, std::map< std::string, std::string > &vars, mp::filter::HttpRewrite::RulePtr ruleptr, bool html_context, std::list< boost::regex > &skip_list)
 
static mp::filter::Base * filter_creator ()
 

Variables

struct metaproxy_1_filter_struct metaproxy_1_filter_http_rewrite
 

Function Documentation

static bool embed_quoted_literal ( std::string &  content,
std::map< std::string, std::string > &  vars,
mp::filter::HttpRewrite::RulePtr  ruleptr,
bool  html_context,
std::list< boost::regex > &  skip_list 
)
static

Definition at line 463 of file filter_http_rewrite.cpp.

References metaproxy_1::filter::HttpRewrite::configure_phase(), metaproxy_1::filter::HttpRewrite::Event::Event(), metaproxy_1::filter::HttpRewrite::req_phase, and metaproxy_1::filter::HttpRewrite::res_phase.

469 {
470  bool replace = false;
471  std::string res;
472  const char *cp = content.c_str();
473  const char *cp0 = cp;
474  while (*cp)
475  {
476  if (html_context && !strncmp(cp, "&quot;", 6))
477  {
478  cp += 6;
479  res.append(cp0, cp - cp0);
480  cp0 = cp;
481  while (*cp)
482  {
483  if (!strncmp(cp, "&quot;", 6))
484  break;
485  if (*cp == '\n')
486  break;
487  cp++;
488  }
489  if (!*cp)
490  break;
491  std::string s(cp0, cp - cp0);
492  if (ruleptr->test_patterns(vars, s, true, skip_list))
493  replace = true;
494  cp0 = cp;
495  res.append(s);
496  }
497  else if (*cp == '"' || *cp == '\'')
498  {
499  int m = *cp;
500  cp++;
501  res.append(cp0, cp - cp0);
502  cp0 = cp;
503  while (*cp)
504  {
505  if (cp[-1] != '\\' && *cp == m)
506  break;
507  if (*cp == '\n')
508  break;
509  cp++;
510  }
511  if (!*cp)
512  break;
513  std::string s(cp0, cp - cp0);
514  if (ruleptr->test_patterns(vars, s, true, skip_list))
515  replace = true;
516  cp0 = cp;
517  res.append(s);
518  }
519  else if (*cp == '/' && cp[1] == '/')
520  {
521  while (cp[1] && cp[1] != '\n')
522  cp++;
523  }
524  cp++;
525  }
526  res.append(cp0, cp - cp0);
527  content = res;
528  return replace;
529 }

Here is the call graph for this function:

static mp::filter::Base* filter_creator ( )
static

Definition at line 966 of file filter_http_rewrite.cpp.

967 {
968  return new mp::filter::HttpRewrite;
969 }

Variable Documentation

struct metaproxy_1_filter_struct metaproxy_1_filter_http_rewrite
Initial value:
= {
0,
"http_rewrite",
}
static mp::filter::Base * filter_creator()

Definition at line 972 of file filter_http_rewrite.cpp.

Referenced by metaproxy_1::FactoryStatic::FactoryStatic().