[Pkg-mozext-commits] [sage-extension] 27/54: feed and item title entity decoding, bug 6514

David Prévot taffit at moszumanska.debian.org
Fri May 1 03:10:38 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to tag sage_1_3
in repository sage-extension.

commit b36fb6322274351a38ff26db89f491e741f5cdf8
Author: Peter Andrews <petea at jhu.edu>
Date:   Thu Sep 30 13:33:43 2004 +0000

    feed and item title entity decoding, bug 6514
---
 src/sage/content/feedlib.js | 30 ++++++++++++++++++++++++------
 src/sage/content/sage.js    |  2 +-
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/src/sage/content/feedlib.js b/src/sage/content/feedlib.js
index 2aeaaf7..93ac359 100644
--- a/src/sage/content/feedlib.js
+++ b/src/sage/content/feedlib.js
@@ -65,13 +65,13 @@ Feed.prototype.parseRSS = function() {
 		if(i.nodeType != i.ELEMENT_NODE) continue;
 		switch(i.localName) {
 			case "title":
-				this.title = CommonFunc.getInnerText(i);
+				this.title = entityDecode(CommonFunc.getInnerText(i));
 				break;
 			case "link":
 				this.link = CommonFunc.getInnerText(i);
 				break;
 			case "description":
-				this.description = CommonFunc.getInnerText(i);
+				this.description = entityDecode(CommonFunc.getInnerText(i));
 				break;
 		}
 	}
@@ -86,7 +86,7 @@ Feed.prototype.parseRSS = function() {
 			if(j.nodeType != j.ELEMENT_NODE) continue;
 			switch(j.localName) {
 				case "title":
-					item.title = CommonFunc.getInnerText(j);
+					item.title = entityDecode(CommonFunc.getInnerText(j));
 					break;
 				case "link":
 					if(!item.link) {
@@ -155,7 +155,7 @@ Feed.prototype.parseAtom = function() {
 		if(i.nodeType != i.ELEMENT_NODE) continue;
 		switch(i.localName) {
 			case "title":
-				this.title = CommonFunc.getInnerText(i);
+				this.title = entityDecode(CommonFunc.getInnerText(i));
 				break;
 			case "link":
 				if(this.link) {
@@ -167,7 +167,7 @@ Feed.prototype.parseAtom = function() {
 				}
 				break;
 			case "tagline":
-				this.description = CommonFunc.getInnerText(i);
+				this.description = entityDecode(CommonFunc.getInnerText(i));
 				break;
 		}
 	}
@@ -178,7 +178,7 @@ Feed.prototype.parseAtom = function() {
 
 		var titleNodes = entryNodes[i].getElementsByTagName("title");
 		if(titleNodes.length) {
-			item.title = CommonFunc.getInnerText(titleNodes[0]);
+			item.title = entityDecode(CommonFunc.getInnerText(titleNodes[0]));
 		}
 
 		var linkNodes = entryNodes[i].getElementsByTagName("link");
@@ -480,3 +480,21 @@ function iso8601ToJSDate(date_str) {
 		return tmp_date;
 	}
 }
+
+function entityDecode(aStr) {
+	var	formatConverter = Components.classes["@mozilla.org/widget/htmlformatconverter;1"].createInstance(Components.interfaces.nsIFormatConverter);
+	var fromStr = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
+	fromStr.data = aStr;
+	var toStr = { value: null };
+
+	try {
+		formatConverter.convert("text/html", fromStr, fromStr.toString().length, "text/unicode", toStr, {});
+	} catch(e) {
+		return aStr;
+	}
+	if(toStr.value) {
+		toStr = toStr.value.QueryInterface(Components.interfaces.nsISupportsString);
+		return toStr.toString();
+	}
+	return aStr;
+}
\ No newline at end of file
diff --git a/src/sage/content/sage.js b/src/sage/content/sage.js
index 027c710..6f198a2 100755
--- a/src/sage/content/sage.js
+++ b/src/sage/content/sage.js
@@ -280,7 +280,7 @@ function setStatusDone() {
 	rssStatusLabel.value = "";
 
 	if(currentFeed) {
-		rssTitleLabel.value = htmlToText(currentFeed.getTitle());
+		rssTitleLabel.value = currentFeed.getTitle();
 		if(currentFeed.getLink()) {
 			rssTitleLabel.setAttribute("href", currentFeed.getLink());
 			rssTitleLabel.tooltipText = currentFeed.getLink();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/sage-extension.git



More information about the Pkg-mozext-commits mailing list