mod_proxy_html.c revision fc42512879dd0504532f52fe5d0d0383dda96a1e
1e83c8de3aa48b316b28057d53995272baf1260cwrowe/* Copyright (c) 2003-11, WebThing Ltd
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * Copyright (c) 2011-, The Apache Software Foundation
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * Licensed to the Apache Software Foundation (ASF) under one or more
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * contributor license agreements. See the NOTICE file distributed with
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * this work for additional information regarding copyright ownership.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * The ASF licenses this file to You under the Apache License, Version 2.0
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * (the "License"); you may not use this file except in compliance with
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * the License. You may obtain a copy of the License at
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * Unless required by applicable law or agreed to in writing, software
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * distributed under the License is distributed on an "AS IS" BASIS,
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * See the License for the specific language governing permissions and
1e83c8de3aa48b316b28057d53995272baf1260cwrowe * limitations under the License.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe/* GO_FASTER
1e83c8de3aa48b316b28057d53995272baf1260cwrowe You can #define GO_FASTER to disable trace logging.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe/* libxml2 */
1e83c8de3aa48b316b28057d53995272baf1260cwrowe/* globals set once at startup */
1e83c8de3aa48b316b28057d53995272baf1260cwrowestatic apr_status_t (*xml2enc_charset)(request_rec*, xmlCharEncoding*, const char**) = NULL;
1e83c8de3aa48b316b28057d53995272baf1260cwrowestatic apr_status_t (*xml2enc_filter)(request_rec*, const char*, unsigned int) = NULL;
1e83c8de3aa48b316b28057d53995272baf1260cwrowetypedef struct {
1e83c8de3aa48b316b28057d53995272baf1260cwrowe const char *val;
5ac28f3fe2417368757f29cf381338357605fd52wrowetypedef struct {
e1ad80c048e29e968221817698529d73098f07a4wrowe unsigned int start;
1e83c8de3aa48b316b28057d53995272baf1260cwrowe unsigned int end;
1e83c8de3aa48b316b28057d53995272baf1260cwrowetypedef struct urlmap {
1e83c8de3aa48b316b28057d53995272baf1260cwrowe unsigned int flags;
1e83c8de3aa48b316b28057d53995272baf1260cwrowe unsigned int regflags;
1e83c8de3aa48b316b28057d53995272baf1260cwrowe const char *c;
1e83c8de3aa48b316b28057d53995272baf1260cwrowe const char *to;
1e83c8de3aa48b316b28057d53995272baf1260cwrowetypedef struct {
1e83c8de3aa48b316b28057d53995272baf1260cwrowe const char *doctype;
1e83c8de3aa48b316b28057d53995272baf1260cwrowe const char *etag;
1e83c8de3aa48b316b28057d53995272baf1260cwrowe unsigned int flags;
1e83c8de3aa48b316b28057d53995272baf1260cwrowe const char *charset_out;
1e83c8de3aa48b316b28057d53995272baf1260cwrowetypedef struct {
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,