Apache HTTPD
Classes | Macros | Typedefs | Enumerations | Functions | Variables
mod_proxy_html.c File Reference
#include <libxml/HTMLparser.h>
#include "http_protocol.h"
#include "http_config.h"
#include "http_log.h"
#include "apr_strings.h"
#include "apr_hash.h"
#include "apr_strmatch.h"
#include "apr_lib.h"
#include "apr_optional.h"
#include "mod_xml2enc.h"
#include "http_request.h"
#include "ap_expr.h"

Go to the source code of this file.

Classes

struct  tattr
 
struct  meta
 
struct  urlmap
 
struct  proxy_html_conf
 
struct  saxctxt
 

Macros

#define VERBOSE(x)   if (verbose) x
 
#define VERBOSEB(x)   if (verbose) {x}
 
#define M_HTML   0x01
 
#define M_EVENTS   0x02
 
#define M_CDATA   0x04
 
#define M_REGEX   0x08
 
#define M_ATSTART   0x10
 
#define M_ATEND   0x20
 
#define M_LAST   0x40
 
#define M_NOTLAST   0x80
 
#define M_INTERPOLATE_TO   0x100
 
#define M_INTERPOLATE_FROM   0x200
 
#define NORM_LC   0x1
 
#define NORM_MSSLASH   0x2
 
#define NORM_RESET   0x4
 
#define DEFAULT_ETAG   html_etag
 
#define consume_buffer(ctx, inbuf, bytes, flag)    htmlParseChunk(ctx->parser, inbuf, bytes, flag)
 
#define AP_fwrite(ctx, inbuf, bytes, flush)    ap_fwrite(ctx->f->next, ctx->bb, inbuf, bytes);
 
#define FLUSH   AP_fwrite(ctx, (chars+begin), (i-begin), 0); begin = i+1
 
#define REGFLAG(n, s, c)   ((s&&(ap_strchr_c((s),(c))!=NULL)) ? (n) : 0)
 
#define XREGFLAG(n, s, c)   ((!s||(ap_strchr_c((s),(c))==NULL)) ? (n) : 0)
 

Typedefs

typedef struct urlmap urlmap
 

Enumerations

enum  rewrite_t { ATTR_IGNORE , ATTR_URI , ATTR_EVENT }
 

Functions

static void normalise (unsigned int flags, char *str)
 
static void pcharacters (void *ctxt, const xmlChar *uchars, int length)
 
static void preserve (saxctxt *ctx, const size_t len)
 
static void pappend (saxctxt *ctx, const char *buf, const size_t len)
 
static void dump_content (saxctxt *ctx)
 
static void pcdata (void *ctxt, const xmlChar *uchars, int length)
 
static void pcomment (void *ctxt, const xmlChar *uchars)
 
static void pendElement (void *ctxt, const xmlChar *uname)
 
static void pstartElement (void *ctxt, const xmlChar *uname, const xmlChar **uattrs)
 
static metametafix (request_rec *r, const char *buf, apr_size_t len)
 
static const charinterpolate_vars (request_rec *r, const char *str)
 
static void fixup_rules (saxctxt *ctx)
 
static saxctxtcheck_filter_init (ap_filter_t *f)
 
static void prepend_rbuf (saxctxt *ctxt, apr_bucket_brigade *bb)
 
static apr_status_t proxy_html_filter (ap_filter_t *f, apr_bucket_brigade *bb)
 
static void * proxy_html_config (apr_pool_t *pool, char *x)
 
static void * proxy_html_merge (apr_pool_t *pool, void *BASE, void *ADD)
 
static const charcomp_urlmap (cmd_parms *cmd, urlmap *newmap, const char *from, const char *to, const char *flags, const char *cond)
 
static const charset_urlmap (cmd_parms *cmd, void *CFG, const char *args)
 
static const charset_doctype (cmd_parms *cmd, void *CFG, const char *t, const char *l)
 
static const charset_flags (cmd_parms *cmd, void *CFG, const char *arg)
 
static const charset_events (cmd_parms *cmd, void *CFG, const char *arg)
 
static const charset_links (cmd_parms *cmd, void *CFG, const char *elt, const char *att)
 
static int mod_proxy_html (apr_pool_t *p, apr_pool_t *p1, apr_pool_t *p2)
 
static void proxy_html_insert (request_rec *r)
 
static void proxy_html_hooks (apr_pool_t *p)
 

Variables

static ap_rxplus_told_expr
 
static ap_regex_tseek_meta
 
static const apr_strmatch_patternseek_content
 
static apr_status_t(* xml2enc_charset )(request_rec *, xmlCharEncoding *, const char **) = NULL
 
static apr_status_t(* xml2enc_filter )(request_rec *, const char *, unsigned int) = NULL
 
static htmlSAXHandler sax
 
static const char *const fpi_html
 
static const char *const fpi_html_legacy
 
static const char *const fpi_xhtml
 
static const char *const fpi_xhtml_legacy
 
static const char *const fpi_html5 = "<!DOCTYPE html>\n"
 
static const char *const html_etag = ">"
 
static const char *const xhtml_etag = " />"
 
static const char *const DEFAULT_DOCTYPE = ""
 
static const command_rec proxy_html_cmds []
 
static int *const aplog_module_index = &( proxy_html_module.module_index)
 

Macro Definition Documentation

◆ AP_fwrite

#define AP_fwrite (   ctx,
  inbuf,
  bytes,
  flush 
)     ap_fwrite(ctx->f->next, ctx->bb, inbuf, bytes);

Definition at line 174 of file mod_proxy_html.c.

◆ consume_buffer

#define consume_buffer (   ctx,
  inbuf,
  bytes,
  flag 
)     htmlParseChunk(ctx->parser, inbuf, bytes, flag)

Definition at line 171 of file mod_proxy_html.c.

◆ DEFAULT_ETAG

#define DEFAULT_ETAG   html_etag

Definition at line 156 of file mod_proxy_html.c.

◆ FLUSH

#define FLUSH   AP_fwrite(ctx, (chars+begin), (i-begin), 0); begin = i+1

Definition at line 178 of file mod_proxy_html.c.

◆ M_ATEND

#define M_ATEND   0x20

Definition at line 81 of file mod_proxy_html.c.

◆ M_ATSTART

#define M_ATSTART   0x10

Definition at line 80 of file mod_proxy_html.c.

◆ M_CDATA

#define M_CDATA   0x04

Definition at line 78 of file mod_proxy_html.c.

◆ M_EVENTS

#define M_EVENTS   0x02

Definition at line 77 of file mod_proxy_html.c.

◆ M_HTML

#define M_HTML   0x01

Definition at line 76 of file mod_proxy_html.c.

◆ M_INTERPOLATE_FROM

#define M_INTERPOLATE_FROM   0x200

Definition at line 85 of file mod_proxy_html.c.

◆ M_INTERPOLATE_TO

#define M_INTERPOLATE_TO   0x100

Definition at line 84 of file mod_proxy_html.c.

◆ M_LAST

#define M_LAST   0x40

Definition at line 82 of file mod_proxy_html.c.

◆ M_NOTLAST

#define M_NOTLAST   0x80

Definition at line 83 of file mod_proxy_html.c.

◆ M_REGEX

#define M_REGEX   0x08

Definition at line 79 of file mod_proxy_html.c.

◆ NORM_LC

#define NORM_LC   0x1

Definition at line 136 of file mod_proxy_html.c.

◆ NORM_MSSLASH

#define NORM_MSSLASH   0x2

Definition at line 137 of file mod_proxy_html.c.

◆ NORM_RESET

#define NORM_RESET   0x4

Definition at line 138 of file mod_proxy_html.c.

◆ REGFLAG

#define REGFLAG (   n,
  s,
  c 
)    ((s&&(ap_strchr_c((s),(c))!=NULL)) ? (n) : 0)

Definition at line 1089 of file mod_proxy_html.c.

◆ VERBOSE

#define VERBOSE (   x)    if (verbose) x

Definition at line 28 of file mod_proxy_html.c.

◆ VERBOSEB

#define VERBOSEB (   x)    if (verbose) {x}

Definition at line 29 of file mod_proxy_html.c.

◆ XREGFLAG

#define XREGFLAG (   n,
  s,
  c 
)    ((!s||(ap_strchr_c((s),(c))==NULL)) ? (n) : 0)

Definition at line 1090 of file mod_proxy_html.c.

Typedef Documentation

◆ urlmap

Enumeration Type Documentation

◆ rewrite_t

Enumerator
ATTR_IGNORE 
ATTR_URI 
ATTR_EVENT 

Definition at line 141 of file mod_proxy_html.c.

Function Documentation

◆ check_filter_init()

static saxctxt * check_filter_init ( ap_filter_t f)
static

Definition at line 822 of file mod_proxy_html.c.

◆ comp_urlmap()

static const char * comp_urlmap ( cmd_parms cmd,
urlmap newmap,
const char from,
const char to,
const char flags,
const char cond 
)
static

unused

use a case-insensitive match

unused

don't match newlines against '.' etc

Definition at line 1091 of file mod_proxy_html.c.

◆ dump_content()

static void dump_content ( saxctxt ctx)
static

Definition at line 223 of file mod_proxy_html.c.

◆ fixup_rules()

static void fixup_rules ( saxctxt ctx)
static

Definition at line 772 of file mod_proxy_html.c.

◆ interpolate_vars()

static const char * interpolate_vars ( request_rec r,
const char str 
)
static

Definition at line 728 of file mod_proxy_html.c.

◆ metafix()

static meta * metafix ( request_rec r,
const char buf,
apr_size_t  len 
)
static

Definition at line 663 of file mod_proxy_html.c.

◆ mod_proxy_html()

static int mod_proxy_html ( apr_pool_t p,
apr_pool_t p1,
apr_pool_t p2 
)
static

unused

use a case-insensitive match

< Module has handled this stage.

Definition at line 1298 of file mod_proxy_html.c.

◆ normalise()

static void normalise ( unsigned int  flags,
char str 
)
static

Definition at line 158 of file mod_proxy_html.c.

◆ pappend()

static void pappend ( saxctxt ctx,
const char buf,
const size_t  len 
)
static

Definition at line 216 of file mod_proxy_html.c.

◆ pcdata()

static void pcdata ( void *  ctxt,
const xmlChar uchars,
int  length 
)
static

Definition at line 305 of file mod_proxy_html.c.

◆ pcharacters()

static void pcharacters ( void *  ctxt,
const xmlChar uchars,
int  length 
)
static

Definition at line 179 of file mod_proxy_html.c.

◆ pcomment()

static void pcomment ( void *  ctxt,
const xmlChar uchars 
)
static

Definition at line 319 of file mod_proxy_html.c.

◆ pendElement()

static void pendElement ( void *  ctxt,
const xmlChar uname 
)
static

Definition at line 338 of file mod_proxy_html.c.

◆ prepend_rbuf()

static void prepend_rbuf ( saxctxt ctxt,
apr_bucket_brigade bb 
)
static

Definition at line 875 of file mod_proxy_html.c.

◆ preserve()

static void preserve ( saxctxt ctx,
const size_t  len 
)
static

Definition at line 197 of file mod_proxy_html.c.

◆ proxy_html_config()

static void * proxy_html_config ( apr_pool_t pool,
char x 
)
static

Definition at line 1026 of file mod_proxy_html.c.

◆ proxy_html_filter()

static apr_status_t proxy_html_filter ( ap_filter_t f,
apr_bucket_brigade bb 
)
static

Definition at line 886 of file mod_proxy_html.c.

◆ proxy_html_hooks()

static void proxy_html_hooks ( apr_pool_t p)
static

Definition at line 1332 of file mod_proxy_html.c.

◆ proxy_html_insert()

static void proxy_html_insert ( request_rec r)
static

Definition at line 1322 of file mod_proxy_html.c.

◆ proxy_html_merge()

static void * proxy_html_merge ( apr_pool_t pool,
void *  BASE,
void *  ADD 
)
static

Definition at line 1037 of file mod_proxy_html.c.

◆ pstartElement()

static void pstartElement ( void *  ctxt,
const xmlChar uname,
const xmlChar **  uattrs 
)
static

Definition at line 368 of file mod_proxy_html.c.

◆ set_doctype()

static const char * set_doctype ( cmd_parms cmd,
void *  CFG,
const char t,
const char l 
)
static

Definition at line 1185 of file mod_proxy_html.c.

◆ set_events()

static const char * set_events ( cmd_parms cmd,
void *  CFG,
const char arg 
)
static

Definition at line 1231 of file mod_proxy_html.c.

◆ set_flags()

static const char * set_flags ( cmd_parms cmd,
void *  CFG,
const char arg 
)
static

Definition at line 1217 of file mod_proxy_html.c.

◆ set_links()

static const char * set_links ( cmd_parms cmd,
void *  CFG,
const char elt,
const char att 
)
static

Definition at line 1242 of file mod_proxy_html.c.

◆ set_urlmap()

static const char * set_urlmap ( cmd_parms cmd,
void *  CFG,
const char args 
)
static

Definition at line 1149 of file mod_proxy_html.c.

Variable Documentation

◆ aplog_module_index

int* const aplog_module_index = &( proxy_html_module.module_index)
static

Definition at line 1345 of file mod_proxy_html.c.

◆ DEFAULT_DOCTYPE

const char* const DEFAULT_DOCTYPE = ""
static

Definition at line 155 of file mod_proxy_html.c.

◆ fpi_html

const char* const fpi_html
static
Initial value:
=
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n"

Definition at line 143 of file mod_proxy_html.c.

◆ fpi_html5

const char* const fpi_html5 = "<!DOCTYPE html>\n"
static

Definition at line 151 of file mod_proxy_html.c.

◆ fpi_html_legacy

const char* const fpi_html_legacy
static
Initial value:
=
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"

Definition at line 145 of file mod_proxy_html.c.

◆ fpi_xhtml

const char* const fpi_xhtml
static
Initial value:
=
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"

Definition at line 147 of file mod_proxy_html.c.

◆ fpi_xhtml_legacy

const char* const fpi_xhtml_legacy
static
Initial value:
=
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"

Definition at line 149 of file mod_proxy_html.c.

◆ html_etag

const char* const html_etag = ">"
static

Definition at line 152 of file mod_proxy_html.c.

◆ old_expr

ap_rxplus_t* old_expr
static

Definition at line 68 of file mod_proxy_html.c.

◆ proxy_html_cmds

const command_rec proxy_html_cmds[]
static

Definition at line 1261 of file mod_proxy_html.c.

◆ sax

htmlSAXHandler sax
static

Definition at line 139 of file mod_proxy_html.c.

◆ seek_content

const apr_strmatch_pattern* seek_content
static

Definition at line 70 of file mod_proxy_html.c.

◆ seek_meta

ap_regex_t* seek_meta
static

Definition at line 69 of file mod_proxy_html.c.

◆ xhtml_etag

const char* const xhtml_etag = " />"
static

Definition at line 153 of file mod_proxy_html.c.

◆ xml2enc_charset

apr_status_t(* xml2enc_charset) (request_rec *, xmlCharEncoding *, const char **) ( request_rec ,
xmlCharEncoding ,
const char **   
) = NULL
static

Definition at line 71 of file mod_proxy_html.c.

◆ xml2enc_filter

apr_status_t(* xml2enc_filter) (request_rec *, const char *, unsigned int) ( request_rec ,
const char ,
unsigned int   
) = NULL
static

Definition at line 72 of file mod_proxy_html.c.