mod_proxy_html.c revision 6ed44e60c0269b7d3d27a250fc7e05fa8b6f4cdb
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith/* Copyright (c) 2003-11, WebThing Ltd
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith * Copyright (c) 2011-, The Apache Software Foundation
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith * Licensed to the Apache Software Foundation (ASF) under one or more
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith * contributor license agreements. See the NOTICE file distributed with
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith * this work for additional information regarding copyright ownership.
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith * The ASF licenses this file to You under the Apache License, Version 2.0
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith * (the "License"); you may not use this file except in compliance with
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith * the License. You may obtain a copy of the License at
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith * Unless required by applicable law or agreed to in writing, software
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith * distributed under the License is distributed on an "AS IS" BASIS,
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith * See the License for the specific language governing permissions and
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith * limitations under the License.
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith/* GO_FASTER
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith You can #define GO_FASTER to disable informational logging.
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith This disables the ProxyHTMLLogVerbose option altogether.
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith Default is to leave it undefined, and enable verbose logging
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith as a configuration option. Binaries are supplied with verbose
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith logging enabled.
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith/* 3.1.2 - trivial changes to fix compile on Windows */
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith/* libxml2 */
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith/* globals set once at startup */
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmithstatic apr_status_t (*xml2enc_charset)(request_rec*, xmlCharEncoding*, const char**) = NULL;
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmithstatic apr_status_t (*xml2enc_filter)(request_rec*, const char*, unsigned int) = NULL;
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmithtypedef struct {
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith const char* val;
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmithtypedef struct {
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith unsigned int start;
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith unsigned int end;
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmithtypedef struct {
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith const char* env;
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith const char* val;
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmithtypedef struct urlmap {
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith unsigned int flags;
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith unsigned int regflags;
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith const char* c;
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith const char* to;
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmithtypedef struct {
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith const char* doctype;
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith const char* etag;
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmith unsigned int flags;
5569cc0f6cf6a35c9f4bff089a4668da6ade3f71gsmithtypedef struct {
const char* encoding;
} saxctxt;
static const char* const fpi_html =
static const char* const fpi_html_legacy =
static const char* const fpi_xhtml =
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
static const char* const fpi_xhtml_legacy =
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
for (p = str; *p; ++p)
if (isupper(*p))
*p = tolower(*p);
int begin;
switch (chars[i]) {
char* newbuf;
(int(*)(void*))free);
urlmap* m;
char* found;
int nmatch;
char* subs;
#ifndef GO_FASTER
offs = 0;
if (!desc)
int required_attrs;
int num_match;
char* subs;
urlmap* m;
char* found;
#ifndef GO_FASTER
#ifdef HAVE_STACK
const void** descp;
int enforce = 0;
if (!desc) {
#ifdef HAVE_STACK
required_attrs = 0;
if (attrs) {
case HTML_INVALID:
*a, name);
case HTML_DEPRECATED:
*a, name);
case HTML_REQUIRED:
if (linkattrs) {
switch (is_uri) {
case ATTR_URI:
num_match = 0;
pmatch, 0)) {
++num_match;
VERBOSE({
ctx->f->r,
f, subs);
++num_match;
0, ctx->f->r,
case ATTR_EVENT:
offs = 0;
VERBOSE({
ctx->f->r,
f, subs);
++num_match;
while (found) {
m->from.c);
m->from.c);
0, ctx->f->r,
++num_match;
case ATTR_IGNORE:
#ifndef GO_FASTER
, int verbose
char* header;
char* content;
char delim;
while (!isalpha(*++p));
if (p != NULL) {
while (*p && isspace(*p))
while (*p && isspace(*++p));
delim = *p++;
for (q = p; *q != delim; ++q);
return ret;
const char* start;
const char* end;
const char* delim;
const char* before;
const char* after;
const char* replacement;
const char* var;
if (delim) {
if (!replacement) {
if (delim)
return str;
const char* thisval;
urlmap* p;
int has_cond;
if (thisval)
if (prev)
if (!f->ctx) {
const char* force;
if (!force) {
if (!f->r->proxyreq) {
else if (!f->r->content_type) {
if (errmsg) {
#ifndef GO_FASTER
return NULL;
fctx->f = f;
return f->ctx;
apr_bucket* b;
const char* buf = 0;
#ifndef USE_OLD_LIBXML2
if (!ctxt)
b = APR_BUCKET_NEXT(b)) {
if (APR_BUCKET_IS_METADATA(b)) {
if (APR_BUCKET_IS_EOS(b)) {
else if (APR_BUCKET_IS_FLUSH(b)) {
== APR_SUCCESS) {
const char* cenc;
if (!xml2enc_charset ||
if (!xml2enc_charset)
ap_set_content_type(f->r,
return rv;
(int(*)(void*))htmlFreeParserCtxt,
#ifndef USE_OLD_LIBXML2
#ifndef GO_FASTER
return APR_SUCCESS;
return ret;
urlmap* a;
#ifndef GO_FASTER
#ifndef GO_FASTER
return conf;
char* eq;
char* cond_copy;
if (eq) {
*eq = 0;
const char* usage =
const char* from;
const char* to;
const char* flags;
return usage;
return usage;
return NULL;
return NULL;
return NULL;
return NULL;
if (!attrs) {
return NULL;
#ifndef GO_FASTER
{ NULL }
server_rec* s)
if (!xml2enc_charset) {
return OK;
if (xml2enc_filter)
NULL,
NULL,