[Pkg-javascript-commits] [pdf.js] 193/210: Making sure we are not importing CRs and BOMs

David Prévot taffit at moszumanska.debian.org
Thu Jun 5 14:21:17 UTC 2014


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

taffit pushed a commit to branch upstream
in repository pdf.js.

commit 812c5accb2edb5c683a6999ab47c722278fc225e
Author: Yury Delendik <ydelendik at mozilla.com>
Date:   Wed May 28 08:25:27 2014 -0500

    Making sure we are not importing CRs and BOMs
---
 external/crlfchecker/normtext.js | 33 +++++++++++++++++++++++++++++++++
 external/importL10n/locales.js   | 12 ++++++++++--
 l10n/bn-BD/metadata.inc          |  2 +-
 l10n/fi/metadata.inc             |  2 +-
 4 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/external/crlfchecker/normtext.js b/external/crlfchecker/normtext.js
new file mode 100644
index 0000000..3bfda0f
--- /dev/null
+++ b/external/crlfchecker/normtext.js
@@ -0,0 +1,33 @@
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
+/* Copyright 2012 Mozilla Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/* jshint node:true */
+
+'use strict';
+
+var fs = require('fs');
+
+function normalizeText(s) {
+ return s.replace(/\r\n?/g, '\n').replace(/\uFEFF/g, '');
+}
+
+var args = process.argv.slice(2);
+
+args.forEach(function (file) {
+  var content = fs.readFileSync(file, 'utf8');
+  content = normalizeText(content);
+  fs.writeFileSync(file, content, 'utf8');
+});
diff --git a/external/importL10n/locales.js b/external/importL10n/locales.js
index aba35ea..f37e8cf 100644
--- a/external/importL10n/locales.js
+++ b/external/importL10n/locales.js
@@ -39,6 +39,10 @@ var langCodes = [
   'zh-TW', 'zu'
 ];
 
+function normalizeText(s) {
+  return s.replace(/\r\n?/g, '\n').replace(/\uFEFF/g, '');
+}
+
 function downloadLanguageFiles(langCode, callback) {
   console.log('Downloading ' + langCode + '...');
 
@@ -60,12 +64,16 @@ function downloadLanguageFiles(langCode, callback) {
   // Download the necessary files for this language.
   files.forEach(function(fileName) {
     var outputPath = path.join(langCode, fileName);
-    var file = fs.createWriteStream(outputPath);
     var url = MOZCENTRAL_ROOT + langCode + MOZCENTRAL_PDFJS_DIR +
               fileName + MOZCENTRAL_RAW_FLAG;
     var request = http.get(url, function(response) {
-      response.pipe(file);
+      var content = '';
+      response.setEncoding('utf8');
+      response.on("data", function(chunk) {
+        content += chunk;
+      });
       response.on('end', function() {
+        fs.writeFileSync(outputPath, normalizeText(content), 'utf8');
         downloadsLeft--;
         if (downloadsLeft === 0) {
           callback();
diff --git a/l10n/bn-BD/metadata.inc b/l10n/bn-BD/metadata.inc
index 818bbfd..fc36a56 100644
--- a/l10n/bn-BD/metadata.inc
+++ b/l10n/bn-BD/metadata.inc
@@ -1,4 +1,4 @@
-    <em:localized>
+    <em:localized>
       <Description>
         <em:locale>bn-BD</em:locale>
         <em:name>পিডিএফ ভিউয়ার</em:name>
diff --git a/l10n/fi/metadata.inc b/l10n/fi/metadata.inc
index 1b8d8b6..19ec00d 100644
--- a/l10n/fi/metadata.inc
+++ b/l10n/fi/metadata.inc
@@ -1,4 +1,4 @@
-    <em:localized>
+    <em:localized>
       <Description>
         <em:locale>fi</em:locale>
         <em:name>PDF Lukuohjelma</em:name>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list