1 --- misc/raptor-1.4.18/src/raptor.h.old 2008-06-20 07:47:38.000000000 +0200
2 +++ misc/build/raptor-1.4.18/src/raptor.h 2012-02-15 16:54:21.000000000 +0100
3 @@ -376,6 +376,7 @@ typedef struct {
4 * @RAPTOR_FEATURE_JSON_EXTRA_DATA: JSON serializer extra top-level data
5 * @RAPTOR_FEATURE_RSS_TRIPLES: Atom/RSS serializer writes extra RDF triples it finds (none, rdf-xml, atom-triples)
6 * @RAPTOR_FEATURE_ATOM_ENTRY_URI: Atom entry URI. If given, generate an Atom Entry Document with the item having the given URI, otherwise generate an Atom Feed Document with any items found.
7 + * @RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES: When reading XML, load external entities.
8 * @RAPTOR_FEATURE_LAST: Internal
10 * Raptor parser, serializer or XML writer features.
11 @@ -416,7 +417,8 @@ typedef enum {
12 RAPTOR_FEATURE_JSON_EXTRA_DATA,
13 RAPTOR_FEATURE_RSS_TRIPLES,
14 RAPTOR_FEATURE_ATOM_ENTRY_URI,
15 - RAPTOR_FEATURE_LAST=RAPTOR_FEATURE_ATOM_ENTRY_URI
16 + RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES,
17 + RAPTOR_FEATURE_LAST=RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES
21 --- misc/raptor-1.4.18/src/raptor_feature.c.old 2008-06-05 08:54:16.000000000 +0200
22 +++ misc/build/raptor-1.4.18/src/raptor_feature.c 2012-02-15 16:55:09.000000000 +0100
23 @@ -89,7 +89,8 @@ static const struct
24 { RAPTOR_FEATURE_JSON_CALLBACK , 6, "jsonCallback", "JSON serializer callback" },
25 { RAPTOR_FEATURE_JSON_EXTRA_DATA , 6, "jsonExtraData", "JSON serializer extra data" },
26 { RAPTOR_FEATURE_RSS_TRIPLES , 6, "rssTriples", "Atom/RSS serializer writes extra RDF triples" },
27 - { RAPTOR_FEATURE_ATOM_ENTRY_URI , 6, "atomEntryUri", "Atom serializer Entry URI" }
28 + { RAPTOR_FEATURE_ATOM_ENTRY_URI , 6, "atomEntryUri", "Atom serializer Entry URI" },
29 + { RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES, 1, "loadExternalEntities", "Load external XML entities." }
33 --- misc/raptor-1.4.18/src/raptor_internal.h.old 2008-06-03 07:04:09.000000000 +0200
34 +++ misc/build/raptor-1.4.18/src/raptor_internal.h 2012-02-15 16:52:08.000000000 +0100
35 @@ -983,6 +983,14 @@ struct raptor_sax2_s {
37 /* base URI for resolving relative URIs or xml:base URIs */
40 + /* call SAX2 handlers if non-0 */
44 + * non 0 if XML entities should be loaded
46 + int feature_load_external_entities;
49 int raptor_sax2_init(void);
50 --- misc/raptor-1.4.18/src/raptor_libxml.c.old 2008-06-14 05:35:27.000000000 +0200
51 +++ misc/build/raptor-1.4.18/src/raptor_libxml.c 2012-02-15 16:52:08.000000000 +0100
52 @@ -142,18 +142,126 @@ raptor_libxml_hasExternalSubset (void* u
54 static xmlParserInputPtr
55 raptor_libxml_resolveEntity(void* user_data,
56 - const xmlChar *publicId, const xmlChar *systemId) {
57 - raptor_sax2* sax2=(raptor_sax2*)user_data;
58 - return libxml2_resolveEntity(sax2->xc, publicId, systemId);
59 + const xmlChar *publicId, const xmlChar *systemId)
61 + raptor_sax2* sax2 = (raptor_sax2*)user_data;
62 + xmlParserCtxtPtr ctxt = sax2->xc;
63 + const unsigned char *uri_string = NULL;
64 + xmlParserInputPtr entity_input;
65 + int load_entity = 0;
68 + uri_string = (const unsigned char *)ctxt->input->filename;
71 + uri_string = (const unsigned char *)ctxt->directory;
73 + load_entity = sax2->feature_load_external_entities;
76 + entity_input = xmlLoadExternalEntity((const char*)uri_string,
77 + (const char*)publicId,
80 + RAPTOR_DEBUG4("Not loading entity URI %s by policy for publicId '%s' systemId '%s'\n", uri_string, publicId, systemId);
83 + return entity_input;
88 -raptor_libxml_getEntity(void* user_data, const xmlChar *name) {
89 - raptor_sax2* sax2=(raptor_sax2*)user_data;
90 - return libxml2_getEntity(sax2->xc, name);
92 +raptor_libxml_getEntity(void* user_data, const xmlChar *name)
94 + raptor_sax2* sax2 = (raptor_sax2*)user_data;
95 + xmlParserCtxtPtr xc = sax2->xc;
96 + xmlEntityPtr ret = NULL;
101 + if(!xc->inSubset) {
102 + /* looks for hardcoded set of entity names - lt, gt etc. */
103 + ret = xmlGetPredefinedEntity(name);
105 + RAPTOR_DEBUG2("Entity '%s' found in predefined set\n", name);
110 + /* This section uses xmlGetDocEntity which looks for entities in
111 + * memory only, never from a file or URI
113 + if(xc->myDoc && (xc->myDoc->standalone == 1)) {
114 + RAPTOR_DEBUG2("Entity '%s' document is standalone\n", name);
115 + /* Document is standalone: no entities are required to interpret doc */
116 + if(xc->inSubset == 2) {
117 + xc->myDoc->standalone = 0;
118 + ret = xmlGetDocEntity(xc->myDoc, name);
119 + xc->myDoc->standalone = 1;
121 + ret = xmlGetDocEntity(xc->myDoc, name);
123 + xc->myDoc->standalone = 0;
124 + ret = xmlGetDocEntity(xc->myDoc, name);
125 + xc->myDoc->standalone = 1;
129 + ret = xmlGetDocEntity(xc->myDoc, name);
132 + if(ret && !ret->children &&
133 + (ret->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) {
134 + /* Entity is an external general parsed entity. It may be in a
135 + * catalog file, user file or user URI
138 + xmlNodePtr children;
139 + int load_entity = 0;
141 + load_entity = sax2->feature_load_external_entities;
144 + RAPTOR_DEBUG2("Not getting entity URI %s by policy\n", ret->URI);
145 + children = xmlNewText((const xmlChar*)"");
147 + /* Disable SAX2 handlers so that the SAX2 events do not all get
148 + * sent to callbacks during dealing with the entity parsing.
151 + val = xmlParseCtxtExternalEntity(xc, ret->URI, ret->ExternalID, &children);
156 + xmlAddChildList((xmlNodePtr)ret, children);
164 +/* ret->checked was added with commit a37a6ad91a61d168ecc4b29263def3363fff4da6
165 + in libxml2 before 2.6.27 it does not exist and ret->children != 0 will be
166 + tested instead, which is true due to xmlAddChildList above */
167 +#if LIBXML_VERSION >= 20627 || !defined(__APPLE__)
168 + /* Mark this entity as having been checked - never do this again */
172 + if (atoi(xmlParserVersion) >= 20627) {
173 + int *const pChecked = (&ret->owner) + 1;
174 + if (!*pChecked) /* owner precedes checked and is also of type int */
185 raptor_libxml_getParameterEntity(void* user_data, const xmlChar *name) {
186 --- misc/raptor-1.4.18/src/raptor_parse.c.old 2008-06-15 09:18:50.000000000 +0200
187 +++ misc/build/raptor-1.4.18/src/raptor_parse.c 2012-02-15 16:52:08.000000000 +0100
188 @@ -1294,6 +1294,7 @@ raptor_set_feature(raptor_parser *parser
189 case RAPTOR_FEATURE_MICROFORMATS:
190 case RAPTOR_FEATURE_HTML_LINK:
191 case RAPTOR_FEATURE_WWW_TIMEOUT:
192 + case RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES:
193 parser->features[(int)feature]=value;
196 @@ -1414,6 +1415,7 @@ raptor_get_feature(raptor_parser *parser
197 case RAPTOR_FEATURE_MICROFORMATS:
198 case RAPTOR_FEATURE_HTML_LINK:
199 case RAPTOR_FEATURE_WWW_TIMEOUT:
200 + case RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES:
201 result=(parser->features[(int)feature] != 0);
204 --- misc/raptor-1.4.18/src/raptor_rdfxml.c.old 2008-06-15 10:12:06.000000000 +0200
205 +++ misc/build/raptor-1.4.18/src/raptor_rdfxml.c 2012-02-15 16:52:08.000000000 +0100
206 @@ -1124,6 +1124,9 @@ raptor_rdfxml_parse_start(raptor_parser*
207 raptor_sax2_set_feature(rdf_xml_parser->sax2,
208 RAPTOR_FEATURE_NO_NET,
209 rdf_parser->features[RAPTOR_FEATURE_NO_NET]);
210 + raptor_sax2_set_feature(rdf_xml_parser->sax2,
211 + RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES,
212 + rdf_parser->features[RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES]);
214 raptor_sax2_parse_start(rdf_xml_parser->sax2, uri);
216 --- misc/raptor-1.4.18/src/raptor_rss.c.old 2008-05-21 22:25:57.000000000 +0200
217 +++ misc/build/raptor-1.4.18/src/raptor_rss.c 2012-02-15 16:52:08.000000000 +0100
218 @@ -251,6 +251,9 @@ raptor_rss_parse_start(raptor_parser *rd
219 raptor_sax2_set_feature(rss_parser->sax2,
220 RAPTOR_FEATURE_NO_NET,
221 rdf_parser->features[RAPTOR_FEATURE_NO_NET]);
222 + raptor_sax2_set_feature(rss_parser->sax2,
223 + RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES,
224 + rdf_parser->features[RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES]);
226 raptor_sax2_parse_start(rss_parser->sax2, uri);
228 --- misc/raptor-1.4.18/src/raptor_sax2.c.old 2008-06-15 10:12:20.000000000 +0200
229 +++ misc/build/raptor-1.4.18/src/raptor_sax2.c 2012-02-15 16:52:08.000000000 +0100
230 @@ -96,6 +96,8 @@ raptor_new_sax2(void* user_data, raptor_
232 sax2->user_data=user_data;
236 sax2->locator=error_handlers->locator;
238 sax2->error_handlers=error_handlers;
239 @@ -687,6 +689,10 @@ raptor_sax2_set_feature(raptor_sax2 *sax
240 sax2->feature_no_net=value;
243 + case RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES:
244 + sax2->feature_load_external_entities=value;
247 case RAPTOR_FEATURE_SCANNING:
248 case RAPTOR_FEATURE_ASSUME_IS_RDF:
249 case RAPTOR_FEATURE_ALLOW_NON_NS_ATTRIBUTES:
250 @@ -767,6 +773,9 @@ raptor_sax2_start_element(void* user_dat
251 unsigned char *xml_language=NULL;
252 raptor_uri *xml_base=NULL;
257 #ifdef RAPTOR_XML_EXPAT
258 #ifdef EXPAT_UTF8_BOM_CRASH
259 sax2->tokens_count++;
260 @@ -990,6 +999,9 @@ raptor_sax2_end_element(void* user_data,
261 raptor_sax2* sax2=(raptor_sax2*)user_data;
262 raptor_xml_element* xml_element;
267 #ifdef RAPTOR_XML_EXPAT
268 #ifdef EXPAT_UTF8_BOM_CRASH
269 sax2->tokens_count++;
270 @@ -1025,6 +1037,10 @@ void
271 raptor_sax2_characters(void* user_data, const unsigned char *s, int len)
273 raptor_sax2* sax2=(raptor_sax2*)user_data;
278 if(sax2->characters_handler)
279 sax2->characters_handler(sax2->user_data, sax2->current_element, s, len);
281 @@ -1035,6 +1051,10 @@ void
282 raptor_sax2_cdata(void* user_data, const unsigned char *s, int len)
284 raptor_sax2* sax2=(raptor_sax2*)user_data;
289 #ifdef RAPTOR_XML_EXPAT
290 #ifdef EXPAT_UTF8_BOM_CRASH
291 sax2->tokens_count++;
292 @@ -1051,6 +1071,10 @@ void
293 raptor_sax2_comment(void* user_data, const unsigned char *s)
295 raptor_sax2* sax2=(raptor_sax2*)user_data;
300 if(sax2->comment_handler)
301 sax2->comment_handler(sax2->user_data, sax2->current_element, s);
303 @@ -1066,6 +1090,10 @@ raptor_sax2_unparsed_entity_decl(void* u
304 const unsigned char* notationName)
306 raptor_sax2* sax2=(raptor_sax2*)user_data;
311 if(sax2->unparsed_entity_decl_handler)
312 sax2->unparsed_entity_decl_handler(sax2->user_data,
313 entityName, base, systemId,
314 @@ -1082,6 +1110,10 @@ raptor_sax2_external_entity_ref(void* us
315 const unsigned char* publicId)
317 raptor_sax2* sax2=(raptor_sax2*)user_data;
322 if(sax2->external_entity_ref_handler)
323 return sax2->external_entity_ref_handler(sax2->user_data,
324 context, base, systemId, publicId);
325 --- misc/raptor-1.4.18/src/raptor_serialize.c.old 2008-06-20 02:55:31.000000000 +0200
326 +++ misc/build/raptor-1.4.18/src/raptor_serialize.c 2012-02-15 16:52:08.000000000 +0100
327 @@ -859,6 +859,7 @@ raptor_serializer_set_feature(raptor_ser
330 case RAPTOR_FEATURE_NO_NET:
331 + case RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES:
333 /* XML writer features */
334 case RAPTOR_FEATURE_WRITER_AUTO_INDENT:
335 @@ -965,6 +966,7 @@ raptor_serializer_set_feature_string(rap
338 case RAPTOR_FEATURE_NO_NET:
339 + case RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES:
341 /* XML writer features */
342 case RAPTOR_FEATURE_WRITER_AUTO_INDENT:
343 @@ -1102,6 +1104,7 @@ raptor_serializer_get_feature(raptor_ser
346 case RAPTOR_FEATURE_NO_NET:
347 + case RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES:
349 /* XML writer features */
350 case RAPTOR_FEATURE_WRITER_AUTO_INDENT:
351 @@ -1201,6 +1204,7 @@ raptor_serializer_get_feature_string(rap
354 case RAPTOR_FEATURE_NO_NET:
355 + case RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES:
357 /* XML writer features */
358 case RAPTOR_FEATURE_WRITER_AUTO_INDENT:
359 --- misc/raptor-1.4.18/src/raptor_turtle_writer.c.old 2008-06-20 07:47:48.000000000 +0200
360 +++ misc/build/raptor-1.4.18/src/raptor_turtle_writer.c 2012-02-15 16:52:08.000000000 +0100
361 @@ -723,6 +723,7 @@ raptor_turtle_writer_set_feature(raptor_
364 case RAPTOR_FEATURE_NO_NET:
365 + case RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES:
367 /* XML writer features */
368 case RAPTOR_FEATURE_RELATIVE_URIS:
369 @@ -836,6 +837,7 @@ raptor_turtle_writer_get_feature(raptor_
372 case RAPTOR_FEATURE_NO_NET:
373 + case RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES:
375 /* XML writer features */
376 case RAPTOR_FEATURE_RELATIVE_URIS:
377 --- misc/raptor-1.4.18/src/raptor_xml_writer.c.old 2008-06-03 07:05:56.000000000 +0200
378 +++ misc/build/raptor-1.4.18/src/raptor_xml_writer.c 2012-02-15 16:52:08.000000000 +0100
379 @@ -906,6 +906,7 @@ raptor_xml_writer_set_feature(raptor_xml
382 case RAPTOR_FEATURE_NO_NET:
383 + case RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES:
385 /* XML writer features */
386 case RAPTOR_FEATURE_RELATIVE_URIS:
387 @@ -1026,6 +1027,7 @@ raptor_xml_writer_get_feature(raptor_xml
390 case RAPTOR_FEATURE_NO_NET:
391 + case RAPTOR_FEATURE_LOAD_EXTERNAL_ENTITIES:
393 /* XML writer features */
394 case RAPTOR_FEATURE_RELATIVE_URIS: