metaproxy  1.21.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

◆ embed_quoted_literal()

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 480 of file filter_http_rewrite.cpp.

486 {
487  bool replace = false;
488  std::string res;
489  const char *cp = content.c_str();
490  const char *cp0 = cp;
491  while (*cp)
492  {
493  if (html_context && !strncmp(cp, "&quot;", 6))
494  {
495  cp += 6;
496  res.append(cp0, cp - cp0);
497  cp0 = cp;
498  while (*cp)
499  {
500  if (!strncmp(cp, "&quot;", 6))
501  break;
502  if (*cp == '\n')
503  break;
504  cp++;
505  }
506  if (!*cp)
507  break;
508  std::string s(cp0, cp - cp0);
509  if (ruleptr->test_patterns(vars, s, true, skip_list))
510  replace = true;
511  cp0 = cp;
512  res.append(s);
513  }
514  else if (*cp == '"' || *cp == '\'')
515  {
516  int m = *cp;
517  cp++;
518  res.append(cp0, cp - cp0);
519  cp0 = cp;
520  while (*cp)
521  {
522  if (cp[-1] != '\\' && *cp == m)
523  break;
524  if (*cp == '\n')
525  break;
526  cp++;
527  }
528  if (!*cp)
529  break;
530  std::string s(cp0, cp - cp0);
531  if (ruleptr->test_patterns(vars, s, true, skip_list))
532  replace = true;
533  cp0 = cp;
534  res.append(s);
535  }
536  else if (*cp == '/' && cp[1] == '/')
537  {
538  while (cp[1] && cp[1] != '\n')
539  cp++;
540  }
541  cp++;
542  }
543  res.append(cp0, cp - cp0);
544  content = res;
545  return replace;
546 }

Referenced by metaproxy_1::filter::HttpRewrite::Within::exec(), and metaproxy_1::filter::HttpRewrite::Content::quoted_literal().

◆ filter_creator()

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

Definition at line 983 of file filter_http_rewrite.cpp.

984 {
985  return new mp::filter::HttpRewrite;
986 }

Variable Documentation

◆ metaproxy_1_filter_http_rewrite

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

Definition at line 983 of file filter_http_rewrite.cpp.

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