r71934 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71933‎ | r71934 | r71935 >
Date:09:57, 30 August 2010
Author:mkroetzsch
Status:ok
Tags:
Comment:
Properly escape % in ENTITY declarations (occurs in URLs in some localisations), fixes Bug 24234
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_OWLExport.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_OWLExport.php
@@ -492,6 +492,10 @@
493493 }
494494
495495 /* Functions for exporting RDF */
 496+
 497+ protected function makeValueEntityString( $string ) {
 498+ return "'" . str_replace( '%','%',$string ) . "'";
 499+ }
496500
497501 protected function printHeader( $ontologyuri = '' ) {
498502 global $wgContLang;
@@ -499,14 +503,14 @@
500504 $this->pre_ns_buffer .=
501505 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" .
502506 "<!DOCTYPE rdf:RDF[\n" .
503 - "\t<!ENTITY rdf '" . SMWExporter::expandURI( '&rdf;' ) . "'>\n" .
504 - "\t<!ENTITY rdfs '" . SMWExporter::expandURI( '&rdfs;' ) . "'>\n" .
505 - "\t<!ENTITY owl '" . SMWExporter::expandURI( '&owl;' ) . "'>\n" .
506 - "\t<!ENTITY swivt '" . SMWExporter::expandURI( '&swivt;' ) . "'>\n" .
 507+ "\t<!ENTITY rdf " . $this->makeValueEntityString( SMWExporter::expandURI( '&rdf;' ) ) . ">\n" .
 508+ "\t<!ENTITY rdfs " . $this->makeValueEntityString( SMWExporter::expandURI( '&rdfs;' ) ) . ">\n" .
 509+ "\t<!ENTITY owl " . $this->makeValueEntityString( SMWExporter::expandURI( '&owl;' ) ) . ">\n" .
 510+ "\t<!ENTITY swivt " . $this->makeValueEntityString( SMWExporter::expandURI( '&swivt;' ) ) . ">\n" .
507511 // A note on "wiki": this namespace is crucial as a fallback when it would be illegal to start e.g. with a number. In this case, one can always use wiki:... followed by "_" and possibly some namespace, since _ is legal as a first character.
508 - "\t<!ENTITY wiki '" . SMWExporter::expandURI( '&wiki;' ) . "'>\n" .
509 - "\t<!ENTITY property '" . SMWExporter::expandURI( '&property;' ) . "'>\n" .
510 - "\t<!ENTITY wikiurl '" . SMWExporter::expandURI( '&wikiurl;' ) . "'>\n" .
 512+ "\t<!ENTITY wiki " . $this->makeValueEntityString( SMWExporter::expandURI( '&wiki;' ) ) . ">\n" .
 513+ "\t<!ENTITY property " . $this->makeValueEntityString( SMWExporter::expandURI( '&property;' ) ) . ">\n" .
 514+ "\t<!ENTITY wikiurl " . $this->makeValueEntityString( SMWExporter::expandURI( '&wikiurl;' ) ) . ">\n" .
511515 "]>\n\n" .
512516 "<rdf:RDF\n" .
513517 "\txmlns:rdf=\"&rdf;\"\n" .

Status & tagging log