From 96462de2f5d8282fa327afa10e2a10f35fd39d4a Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 18 May 2013 16:59:53 +0100 Subject: [PATCH] Fix problem with not encoding body of non-base64 data URIs --- core/modules/widgets/datauri.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/modules/widgets/datauri.js b/core/modules/widgets/datauri.js index ea4d12e81..a7920cf54 100644 --- a/core/modules/widgets/datauri.js +++ b/core/modules/widgets/datauri.js @@ -28,8 +28,13 @@ DataUriWidget.prototype.generate = function() { if(tiddler) { var type = tiddler.fields.type || "text/vnd.tiddlywiki", typeInfo = $tw.config.contentTypeInfo[type], - isBase64 = typeInfo && typeInfo.encoding === "base64"; - uri = "data:" + type + (isBase64 ? ";base64" : "") + "," + tiddler.fields.text; + isBase64 = typeInfo && typeInfo.encoding === "base64", + parts = ["data:"]; + parts.push(type); + parts.push(isBase64 ? ";base64" : ""); + parts.push(","); + parts.push(isBase64 ? tiddler.fields.text : encodeURIComponent(tiddler.fields.text)); + uri = parts.join(""); } // Set the element this.tag = "pre"; @@ -45,4 +50,4 @@ DataUriWidget.prototype.generate = function() { exports.datauri = DataUriWidget; -})(); +})(); \ No newline at end of file