mod_proxy_html.c revision 44b929bbfe63d3b47d3c7481de2b6cead60ee1cd
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin/* Copyright (c) 2003-11, WebThing Ltd
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin * Copyright (c) 2011-, The Apache Software Foundation
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin * Licensed to the Apache Software Foundation (ASF) under one or more
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin * contributor license agreements. See the NOTICE file distributed with
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin * this work for additional information regarding copyright ownership.
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin * The ASF licenses this file to You under the Apache License, Version 2.0
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin * (the "License"); you may not use this file except in compliance with
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin * the License. You may obtain a copy of the License at
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin * Unless required by applicable law or agreed to in writing, software
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin * distributed under the License is distributed on an "AS IS" BASIS,
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin * See the License for the specific language governing permissions and
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin * limitations under the License.
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin/* GO_FASTER
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin You can #define GO_FASTER to disable trace logging.
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin/* libxml2 */
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin/* globals set once at startup */
4a3b6b890a52931991a7ed042d5973ef2039c623minfrinstatic apr_status_t (*xml2enc_charset)(request_rec*, xmlCharEncoding*, const char**) = NULL;
4a3b6b890a52931991a7ed042d5973ef2039c623minfrinstatic apr_status_t (*xml2enc_filter)(request_rec*, const char*, unsigned int) = NULL;
4a3b6b890a52931991a7ed042d5973ef2039c623minfrintypedef struct {
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin const char *val;
4a3b6b890a52931991a7ed042d5973ef2039c623minfrintypedef struct {
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin unsigned int start;
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin unsigned int end;
4a3b6b890a52931991a7ed042d5973ef2039c623minfrintypedef struct urlmap {
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin unsigned int flags;
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin unsigned int regflags;
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin const char *c;
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin const char *to;
4a3b6b890a52931991a7ed042d5973ef2039c623minfrintypedef struct {
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin const char *doctype;
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin const char *etag;
4a3b6b890a52931991a7ed042d5973ef2039c623minfrin unsigned int flags;
int interp;
int enabled;
ap_filter_t *f;
char *buf;
const char *encoding;
const char *etag;
} 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 (externalID) {
if (sysID)
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:
char *header;
char *content;
char delim;
while (!apr_isalpha(*++p));
if (p != NULL) {
while (apr_isspace(*p))
while (*p && apr_isspace(*++p));
delim = *p++;
for (q = p; *q && *q != delim; ++q);
if (*q != delim)
#ifndef GO_FASTER
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;
urlmap *p;
const char *err;
if (err) {
if (ok == 0) {
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
return APR_SUCCESS;
return ret;
urlmap *a;
return conf;
return err;
const char *usage =
const char *from;
const char *to;
const char *flags;
return usage;
return usage;
return NULL;
return NULL;
return NULL;
if (!attrs) {
return NULL;
{ NULL }
if (!xml2enc_charset) {
return OK;
if (xml2enc_filter)
NULL,
NULL,