www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 9665e67042a796a7bb396e25d18b9507257f4878
parent a56422be2c4b5f951f2eb9b8edd5e079ce8fd16a
Author: Dan Stillman <dstillman@zotero.org>
Date:   Wed, 21 Nov 2012 19:42:47 -0500

Fix reports for notes with "&nbsp;" displaying as HTML markup

Reports are now always served as text/html

Diffstat:
Mchrome/content/zotero/xpcom/report.js | 11++++++-----
Mcomponents/zotero-protocol-handler.js | 16+---------------
2 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/chrome/content/zotero/xpcom/report.js b/chrome/content/zotero/xpcom/report.js @@ -41,9 +41,8 @@ Zotero.Report = new function() { function generateHTMLDetails(items, combineChildItems) { - var content = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '; - content += '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n'; - content += '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n'; + var content = '<!DOCTYPE html>\n'; + content += '<html>\n'; content += '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n'; content += '<title>' + Zotero.getString('report.title.default') + '</title>\n'; content += '<link rel="stylesheet" type="text/css" href="zotero://report/detail.css"/>\n'; @@ -80,8 +79,9 @@ Zotero.Report = new function() { // If not valid XML, display notes with entities encoded var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"] .createInstance(Components.interfaces.nsIDOMParser); - var doc = parser.parseFromString('<div>' + arr.note + '</div>', "application/xml"); + var doc = parser.parseFromString('<div>' + arr.note.replace(/&nbsp;/g, "&#160;") + '</div>', "application/xml"); if (doc.documentElement.tagName == 'parsererror') { + Zotero.debug(doc.documentElement.textContent, 2); content += '<p class="plaintext">' + escapeXML(arr.note) + '</p>\n'; } // Otherwise render markup normally @@ -106,8 +106,9 @@ Zotero.Report = new function() { // If not valid XML, display notes with entities encoded var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"] .createInstance(Components.interfaces.nsIDOMParser); - var doc = parser.parseFromString('<div>' + note.note + '</div>', "application/xml"); + var doc = parser.parseFromString('<div>' + note.note.replace(/&nbsp;/g, "&#160;") + '</div>', "application/xml"); if (doc.documentElement.tagName == 'parsererror') { + Zotero.debug(doc.documentElement.textContent, 2); content += '<p class="plaintext">' + escapeXML(note.note) + '</p>\n'; } // Otherwise render markup normally diff --git a/components/zotero-protocol-handler.js b/components/zotero-protocol-handler.js @@ -479,21 +479,7 @@ function ChromeExtensionHandler() { default: var content = Zotero.Report.generateHTMLDetails(items, combineChildItems); - - // Serve invalid XML as text/html - // - // This is a temporary workaround until we figure out - // something better. - try { - var xml = new XML(content.replace(/^<\!DOCTYPE [^>]+>\n/, '').trim()); - mimeType = 'application/xhtml+xml'; - } - catch (e) { - Zotero.debug(e); - mimeType = 'text/html'; - } - - format = 'html'; + mimeType = 'text/html'; } } catch (e){