mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 786169 - Corrupt non-latin text into debugger; r=msucan
This commit is contained in:
parent
45661cd6b6
commit
d85c86687c
@ -1272,6 +1272,7 @@ SourceScripts.prototype = {
|
||||
return self._logError(url, aStatus);
|
||||
}
|
||||
let source = NetUtil.readInputStreamToString(aStream, aStream.available());
|
||||
source = self._convertToUnicode(source);
|
||||
self._onLoadSourceFinished(url, source, null, options);
|
||||
aStream.close();
|
||||
});
|
||||
@ -1296,8 +1297,8 @@ SourceScripts.prototype = {
|
||||
if (!Components.isSuccessCode(aStatusCode)) {
|
||||
return self._logError(url, aStatusCode);
|
||||
}
|
||||
self._onLoadSourceFinished(
|
||||
url, chunks.join(""), channel.contentType, options);
|
||||
let source = self._convertToUnicode(chunks.join(""), channel.contentCharset);
|
||||
self._onLoadSourceFinished(url, source, channel.contentType, options);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1307,6 +1308,28 @@ SourceScripts.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert a given string, encoded in a given character set, to unicode.
|
||||
* @param string aString
|
||||
* A string.
|
||||
* @param string aCharset
|
||||
* A character set.
|
||||
* @return string
|
||||
* A unicode string.
|
||||
*/
|
||||
_convertToUnicode: function SS__convertToUnicode(aString, aCharset) {
|
||||
// Decoding primitives.
|
||||
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
|
||||
.createInstance(Ci.nsIScriptableUnicodeConverter);
|
||||
|
||||
try {
|
||||
converter.charset = aCharset || "UTF-8";
|
||||
return converter.ConvertToUnicode(aString);
|
||||
} catch(e) {
|
||||
return aString;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Called when a script's source has been loaded.
|
||||
*
|
||||
|
@ -70,6 +70,8 @@ function test()
|
||||
|
||||
isnot(editor.getText().indexOf("debugger"), -1,
|
||||
"The correct script was loaded initially.");
|
||||
isnot(editor.getText().indexOf("\u263a"), -1,
|
||||
"Unicode characters are converted correctly.");
|
||||
|
||||
contextMenu = gDebugger.document.getElementById("sourceEditorContextMenu");
|
||||
ok(contextMenu, "source editor context menupopup");
|
||||
|
@ -2,6 +2,6 @@
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function secondCall() {
|
||||
// This comment is useful for browser_dbg_select-line.js.
|
||||
// This comment is useful for browser_dbg_select-line.js. ☺
|
||||
eval("debugger;");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user