From 944d2d39eaf67deda66d10b9f84b525caea60993 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 23 Mar 2006 16:56:29 +0000 Subject: [PATCH] xmlent now defaults to no stripping on the PIs and comments. later, non-stripping of other data will be added git-svn-id: svn://svn.open-ils.org/ILS/trunk@3418 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/apachemods/mod_xmlent.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Open-ILS/src/apachemods/mod_xmlent.c b/Open-ILS/src/apachemods/mod_xmlent.c index 7fa3f47387..adbb91b5ea 100644 --- a/Open-ILS/src/apachemods/mod_xmlent.c +++ b/Open-ILS/src/apachemods/mod_xmlent.c @@ -18,11 +18,9 @@ /* Define the config defaults here */ #define MODXMLENT_CONFIG_STRIP_COMMENTS "XMLEntStripComments" -#define MODXMLENT_CONFIG_STRIP_COMMENTS_DEFAULT "yes" #define MODXMLENT_CONFIG_CONTENT_TYPE "XMLEntContentType" #define MODXMLENT_CONFIG_CONTENT_TYPE_DEFAULT "text/html" #define MODXMLENT_CONFIG_STRIP_PI "XMLEntStripPI" -#define MODXMLENT_CONFIG_STRIP_PI_DEFAULT "yes" #define MODXMLENT_CONFIG_DOCTYPE "XMLEntDoctype" module AP_MODULE_DECLARE_DATA xmlent_module; @@ -49,6 +47,7 @@ static const char* xmlEntSetContentType(cmd_parms *params, void *cfg, const char return NULL; } + /* get the stip PI flag from the config */ static const char* xmlEntSetStripPI(cmd_parms *params, void *cfg, const char *arg) { xmlEntConfig* config = (xmlEntConfig*) cfg; @@ -89,12 +88,8 @@ static const command_rec xmlEntCommands[] = { static void* xmlEntCreateDirConfig( apr_pool_t* p, char* dir ) { xmlEntConfig* config = (xmlEntConfig*) apr_palloc( p, sizeof(xmlEntConfig) ); - config->stripComments = - (MODXMLENT_CONFIG_STRIP_COMMENTS_DEFAULT && - !strcasecmp(MODXMLENT_CONFIG_STRIP_COMMENTS_DEFAULT, "yes")) ? 1 : 0; - config->stripPI = - (MODXMLENT_CONFIG_STRIP_PI_DEFAULT && - !strcasecmp(MODXMLENT_CONFIG_STRIP_PI_DEFAULT, "yes")) ? 1 : 0; + config->stripComments = 0; + config->stripPI = 0; config->contentType = MODXMLENT_CONFIG_CONTENT_TYPE_DEFAULT; config->doctype = NULL; return (void*) config; @@ -177,6 +172,11 @@ static void XMLCALL handlePI( void* userData, const XML_Char* target, const XML_ _fwrite(filter, "", target, data); } +static void XMLCALL handleComment( void* userData, const XML_Char* comment ) { + ap_filter_t* filter = (ap_filter_t*) userData; + _fwrite(filter, "", comment); +} + /* Ends an XML element */ static void XMLCALL endElement(void *userData, const char *name) { ap_filter_t* filter = (ap_filter_t*) userData; @@ -200,7 +200,9 @@ static int xmlEntHandler( ap_filter_t *f, apr_bucket_brigade *brigade ) { f->r->per_dir_config, &xmlent_module ); ap_log_rerror(APLOG_MARK, APLOG_DEBUG, - 0, f->r, "XMLENT Content Type = %s", config->contentType); + 0, f->r, "XMLENT Config: Content Type = %s," + "Strip PI = %d, Strip Comments = %d, Doctype = %s", + config->contentType, config->stripPI, config->stripComments, config->doctype); /* set the content type based on the config */ ap_set_content_type(f->r, config->contentType); @@ -216,6 +218,8 @@ static int xmlEntHandler( ap_filter_t *f, apr_bucket_brigade *brigade ) { XML_SetCharacterDataHandler(parser, charHandler); if(!config->stripPI) XML_SetProcessingInstructionHandler(parser, handlePI); + if(!config->stripComments) + XML_SetCommentHandler(parser, handleComment); } /* create the filter context */ -- 2.43.2