From a09c43d456675992ccff76220e88056e14cc2986 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Thu, 8 Dec 2011 12:45:26 +0000 Subject: [PATCH] Added support for hexadecimal HTML entities --- js/Utils.js | 8 ++++++-- test/wikitests/Fourth Tiddler.html | 2 +- test/wikitests/Fourth Tiddler.tid | 2 +- test/wikitests/Fourth Tiddler.txt | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/js/Utils.js b/js/Utils.js index ad3a26a15..b0e26050f 100755 --- a/js/Utils.js +++ b/js/Utils.js @@ -69,8 +69,12 @@ utils.htmlDecode = function(s) // Converts all HTML entities to their character equivalents utils.entityDecode = function(s) { var e = s.substr(1,s.length-2); // Strip the & and the ; - if(e.charAt(0) == "#") { - return String.fromCharCode(parseInt(e.substr(1),10)); + if(e.charAt(0) === "#") { + if(e.charAt(1) === "x" || e.charAt(1) === "X") { + return String.fromCharCode(parseInt(e.substr(2),16)); + } else { + return String.fromCharCode(parseInt(e.substr(1),10)); + } } else { var c = utils.htmlEntities[e]; if(c) { diff --git a/test/wikitests/Fourth Tiddler.html b/test/wikitests/Fourth Tiddler.html index 2e3adc1ed..0b73533cb 100644 --- a/test/wikitests/Fourth Tiddler.html +++ b/test/wikitests/Fourth Tiddler.html @@ -1 +1 @@ -An image and a couple of Ç "HTML Entity" \ No newline at end of file +An image and a couple of Ç Ç "HTML Entity" \ No newline at end of file diff --git a/test/wikitests/Fourth Tiddler.tid b/test/wikitests/Fourth Tiddler.tid index c4e45ba87..32ef0da4a 100644 --- a/test/wikitests/Fourth Tiddler.tid +++ b/test/wikitests/Fourth Tiddler.tid @@ -1,3 +1,3 @@ title: Fourth Tiddler -An image [img[Something.jpg]] and a couple of Ç "HTML Entity" \ No newline at end of file +An image [img[Something.jpg]] and a couple of Ç Ç "HTML Entity" \ No newline at end of file diff --git a/test/wikitests/Fourth Tiddler.txt b/test/wikitests/Fourth Tiddler.txt index 0a9d51b14..d22d23098 100644 --- a/test/wikitests/Fourth Tiddler.txt +++ b/test/wikitests/Fourth Tiddler.txt @@ -1 +1 @@ -An image and a couple of Ç "HTML Entity" \ No newline at end of file +An image and a couple of Ç Ç "HTML Entity" \ No newline at end of file