logo       

[MediaWiki-CVS] SVN: [54126] trunk/extensions/Translate/ffs/OpenLayers.php: msg#01504

mediawiki-cvs

Subject: [MediaWiki-CVS] SVN: [54126] trunk/extensions/Translate/ffs/OpenLayers.php

http://www.mediawiki.org/wiki/Special:Code/MediaWiki/54126

Revision: 54126
Author: roberthl
Date: 2009-07-31 21:47:48 +0000 (Fri, 31 Jul 2009)

Log Message:
-----------
Translate:
* Add function to OpenLayers FFS for unescaping escaped JS strings, needs
implementing in new FFS system.

Modified Paths:
--------------
trunk/extensions/Translate/ffs/OpenLayers.php

Modified: trunk/extensions/Translate/ffs/OpenLayers.php
===================================================================
--- trunk/extensions/Translate/ffs/OpenLayers.php 2009-07-31 21:07:58 UTC
(rev 54125)
+++ trunk/extensions/Translate/ffs/OpenLayers.php 2009-07-31 21:47:48 UTC
(rev 54126)
@@ -10,6 +10,33 @@

class OpenLayersFormatReader extends SimpleFormatReader {

+ private static function unescapeJsString( $string ) {
+ // See ECMA 262 section 7.8.4 for string literal format
+ $pairs = array(
+ "\\" => "\\\\",
+ "\"" => "\\\"",
+ '\'' => '\\\'',
+ "\n" => "\\n",
+ "\r" => "\\r",
+
+ # To avoid closing the element or CDATA section
+ "<" => "\\x3c",
+ ">" => "\\x3e",
+
+ # To avoid any complaints about bad entity refs
+ "&" => "\\x26",
+
+ # Work around
https://bugzilla.mozilla.org/show_bug.cgi?id=274152
+ # Encode certain Unicode formatting chars so affected
+ # versions of Gecko don't misinterpret our strings;
+ # this is a common problem with Farsi text.
+ "\xe2\x80\x8c" => "\\u200c", // ZERO WIDTH NON-JOINER
+ "\xe2\x80\x8d" => "\\u200d", // ZERO WIDTH JOINER
+ );
+ $pairs = array_flip( $pairs );
+ return strtr( $string, $pairs );
+ }
+
private function leftTrim( $string ) {
$string = ltrim( $string );
$string = ltrim( $string, '"' );
@@ -61,7 +88,7 @@
// Remove quotation marks and syntax.
$key = substr( $key, 1 );
$value = substr( $value, 1, -1 );
- $messages[ $key ] = $value;
+ $messages[ $key ] = self::unescapeJsString( $value );
}

// Remove extraneous key that is sometimes present.



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@xxxxxxxxxxxxxxxxxxx
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise