r21329 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21328‎ | r21329 | r21330 >
Date:16:41, 17 April 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Fixed encoding for HTML entities in XSD values for strings (using Sanitizer).
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Datatype.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Datatype.php
@@ -628,7 +628,7 @@
629629
630630 function processValue($value,&$datavalue) {
631631 if ($value!='') { //do not accept empty strings
632 - $xsdvalue = $value; // encoding is already done by MediaWiki, don't do it twice
 632+ $xsdvalue = smwfXMLContentEncode($value);
633633 // 255 below matches smw_attributes.value_xsd definition in smwfMakeSemanticTables()
634634 // Note that depending on database encoding and UTF-8 settings, longer or
635635 // shorter strings than this with int'l characters may exceed database field.
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -362,10 +362,12 @@
363363
364364 /**
365365 * Escapes text in a way that allows it to be used as XML
366 - * content (e.g. as an string value for some property).
 366+ * content (e.g. as a string value for some property).
367367 */
368368 function smwfXMLContentEncode($text) {
369 - return str_replace(array('&','<','>'),array('&amp;','&lt;','&gt;'),$text);
 369+ global $IP;
 370+ include_once($IP . '/includes/Sanitizer.php');
 371+ return Sanitizer::normalizeCharReferences($text);
370372 }
371373
372374 /**

Status & tagging log