metaproxy 1.22.1
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 <stdlib.h>
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

namespace  metaproxy_1
 
namespace  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 481 of file filter_http_rewrite.cpp.

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

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

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

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

990 {
991 0,
992 "http_rewrite",
994 };

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