From 857d0545dac163418d3ca7e4bc8dad3fd362e96c Mon Sep 17 00:00:00 2001 From: Laurence Withers Date: Tue, 13 Jan 2009 13:39:43 +0000 Subject: [PATCH] Don't expand entities in data when !expandEntities If ctx->expandEntities is false, then don't expand entities in data. Patch from Bob Dunlop, . I'm not 100% sure of the correctness of the behaviour of entity expansion in general -- shouldn't expandEntities toggle between either doing an entity content lookup and substituting the result in the data, or causing a specific "there's an entity here" callback? At present it seems to toggle between lookup/substitute and treating entities (including their leading ampersands) as character data, which seems wrong. To be reviewed. --- src/libCStreamedXML/300_parser.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libCStreamedXML/300_parser.c b/src/libCStreamedXML/300_parser.c index 8966bde..998ccff 100644 --- a/src/libCStreamedXML/300_parser.c +++ b/src/libCStreamedXML/300_parser.c @@ -1,6 +1,6 @@ /* libCStreamedXML/src/libCStreamedXML/300_parser.c * - * (c)2006, Laurence Withers. Released under the GNU GPL. See file + * (c)2006-2009, Laurence Withers. Released under the GNU GPL. See file * COPYING for more information / terms of license. */ @@ -216,10 +216,13 @@ int csxml_feedChar(struct csxml* ctx, char ch) break; case ClassEntity: - ctx->parsingAttr = 0; - ctx->state = StateEntity; - break; + if(ctx->expandEntities) { + ctx->parsingAttr = 0; + ctx->state = StateEntity; + break; + } + /* fall through */ default: APPEND_CH(buffer, ch); break;