Skip to content

Commit

Permalink
Insert a UTF-8 BOM to fix "Show script source".
Browse files Browse the repository at this point in the history
Fixes #1940
  • Loading branch information
janekptacijarabaci authored and arantius committed Jul 31, 2014
1 parent 75372b2 commit ef976d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/parseScript.js
Expand Up @@ -12,7 +12,7 @@ var gIoService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var gLineSplitRegexp = /.+/g;
var gAllMetaRegexp = new RegExp(
'^// ==UserScript==([\\s\\S]*?)^// ==/UserScript==', 'm');
'^(\u00EF\u00BB\u00BF)?// ==UserScript==([\\s\\S]*?)^// ==/UserScript==', 'm');
var gMetaLineRegexp = new RegExp('// @(\\S+)(?:\\s+(.*))?');
var gStringBundle = Components
.classes["@mozilla.org/intl/stringbundle;1"]
Expand All @@ -22,7 +22,7 @@ var gStringBundle = Components
/** Get just the stuff between ==UserScript== lines. */
function extractMeta(aSource) {
var meta = aSource.match(gAllMetaRegexp);
if (meta) return meta[1].replace(/^\s+/, '');
if (meta) return meta[2].replace(/^\s+/, '');
return '';
}

Expand Down
1 change: 1 addition & 0 deletions modules/remoteScript.js
Expand Up @@ -95,6 +95,7 @@ function DownloadListener(
this._fileOutputStream = Cc["@mozilla.org/network/file-output-stream;1"]
.createInstance(Ci.nsIFileOutputStream);
this._fileOutputStream.init(aFile, -1, -1, null);
this._fileOutputStream.write('\u00EF\u00BB\u00BF', 3); // UTF-8 BOM
this._binOutputStream = Cc['@mozilla.org/binaryoutputstream;1']
.createInstance(Ci.nsIBinaryOutputStream);
this._binOutputStream.setOutputStream(this._fileOutputStream);
Expand Down

0 comments on commit ef976d6

Please sign in to comment.