[Pkg-mozext-commits] [greasemonkey] 05/15: Insert a UTF-8 BOM to fix "Show script source".

David Prévot taffit at moszumanska.debian.org
Sat Aug 2 12:51:55 UTC 2014


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

taffit pushed a commit to branch master
in repository greasemonkey.

commit ef976d6448b2d2e4d17362d6d627796d0e6799f0
Author: janekptacijarabaci <janekptacijarabaci at centrum.cz>
Date:   Tue Jul 29 23:33:15 2014 +0200

    Insert a UTF-8 BOM to fix "Show script source".
    
    Fixes #1940
---
 modules/parseScript.js  | 4 ++--
 modules/remoteScript.js | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/parseScript.js b/modules/parseScript.js
index e255951..f0cc154 100644
--- a/modules/parseScript.js
+++ b/modules/parseScript.js
@@ -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"]
@@ -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 '';
 }
 
diff --git a/modules/remoteScript.js b/modules/remoteScript.js
index dc23035..91cddf9 100644
--- a/modules/remoteScript.js
+++ b/modules/remoteScript.js
@@ -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);

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



More information about the Pkg-mozext-commits mailing list