[Pkg-mozext-commits] [perspectives-extension] 33/72: fixed in add_der_header: escape and unescape base64 string for UTF8 safety removed base64
David Prévot
taffit at moszumanska.debian.org
Thu Dec 11 02:12:48 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository perspectives-extension.
commit bf6e440b0f772941daeb010b1bf02fbfc6388851
Author: Gerold Meisinger <gerold.meisinger at gmail.com>
Date: Sat Oct 18 13:08:35 2014 +0100
fixed in add_der_header: escape and unescape base64 string for UTF8 safety
removed base64
---
plugin/chrome/content/base64.js | 168 ---------------------------
plugin/chrome/content/common.js | 4 +-
plugin/chrome/content/preferences_dialog.xul | 1 -
plugin/chrome/content/statusbar.xul | 1 -
test/test.html | 3 -
5 files changed, 2 insertions(+), 175 deletions(-)
diff --git a/plugin/chrome/content/base64.js b/plugin/chrome/content/base64.js
deleted file mode 100644
index a4baab3..0000000
--- a/plugin/chrome/content/base64.js
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
-* This file is part of the Perspectives Firefox Client
-*
-* Copyright (C) 2011 Dan Wendlandt
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, version 3 of the License.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/**
-*
-* Base64 encode / decode
-* http://www.webtoolkit.info/
-*
-* This code was downloaded from the above website on 12-10-2008
-*
-* According to http://jcay.org/javascript/web-sites/webtoolkit.html
-* this code has an MIT license.
-*
-**/
-
-// NOTE: I got rid of the utf8 encoding done by the original code, as we
-// need to replicate base64 encoding/decoding of ASCII strings
-
-var Pers_Base64 = {
-
- // private property
- _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
-
- // public method for encoding
- encode : function (input) {
- var output = "";
- var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
- var i = 0;
-
- while (i < input.length) {
-
- chr1 = input.charCodeAt(i++);
- chr2 = input.charCodeAt(i++);
- chr3 = input.charCodeAt(i++);
-
- enc1 = chr1 >> 2;
- enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
- enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
- enc4 = chr3 & 63;
-
- if (isNaN(chr2)) {
- enc3 = enc4 = 64;
- } else if (isNaN(chr3)) {
- enc4 = 64;
- }
-
- output = output +
- this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
- this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
-
- }
-
- return output;
- },
-
- // public method for decoding
- decode : function (input) {
- var output = "";
- var chr1, chr2, chr3;
- var enc1, enc2, enc3, enc4;
- var i = 0;
-
- input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
-
- while (i < input.length) {
-
- enc1 = this._keyStr.indexOf(input.charAt(i++));
- enc2 = this._keyStr.indexOf(input.charAt(i++));
- enc3 = this._keyStr.indexOf(input.charAt(i++));
- enc4 = this._keyStr.indexOf(input.charAt(i++));
-
- chr1 = (enc1 << 2) | (enc2 >> 4);
- chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
- chr3 = ((enc3 & 3) << 6) | enc4;
-
- output = output + String.fromCharCode(chr1);
-
- if (enc3 != 64) {
- output = output + String.fromCharCode(chr2);
- }
- if (enc4 != 64) {
- output = output + String.fromCharCode(chr3);
- }
-
- }
-
- return output;
-
- },
-
- // private method for UTF-8 encoding
- _utf8_encode : function (string) {
- string = string.replace(/\r\n/g,"\n");
- var utftext = "";
-
- for (var n = 0; n < string.length; n++) {
-
- var c = string.charCodeAt(n);
-
- if (c < 128) {
- utftext += String.fromCharCode(c);
- }
- else if((c > 127) && (c < 2048)) {
- utftext += String.fromCharCode((c >> 6) | 192);
- utftext += String.fromCharCode((c & 63) | 128);
- }
- else {
- utftext += String.fromCharCode((c >> 12) | 224);
- utftext += String.fromCharCode(((c >> 6) & 63) | 128);
- utftext += String.fromCharCode((c & 63) | 128);
- }
-
- }
-
- return utftext;
- },
-
- // private method for UTF-8 decoding
- _utf8_decode : function (utftext) {
- var string = "";
- var i = 0;
- var c;
- var c1;
- var c2;
- var c3;
- c = c1 = c2 = c3 = 0;
-
- while ( i < utftext.length ) {
-
- c = utftext.charCodeAt(i);
-
- if (c < 128) {
- string += String.fromCharCode(c);
- i++;
- }
- else if((c > 191) && (c < 224)) {
- c2 = utftext.charCodeAt(i+1);
- string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
- i += 2;
- }
- else {
- c2 = utftext.charCodeAt(i+1);
- c3 = utftext.charCodeAt(i+2);
- string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
- i += 3;
- }
-
- }
-
- return string;
- }
-
-}
diff --git a/plugin/chrome/content/common.js b/plugin/chrome/content/common.js
index cd74137..ffff38b 100644
--- a/plugin/chrome/content/common.js
+++ b/plugin/chrome/content/common.js
@@ -210,7 +210,7 @@ var Pers_util = {
// here, and re-encode the signature in base64.
// see firefox-v2/xp_src/moz_crypto.cpp for details of header format
add_der_signature_header: function(sig_base64) {
- var base_str = window.atob(sig_base64);
+ var base_str = decodeURIComponent(window.atob(sig_base64));
var der_header_md5 = ["0x30", "0x81", "0xbf", "0x30", "0x0d", "0x06",
"0x09", "0x2a", "0x86", "0x48", "0x86", "0xf7",
"0x0d", "0x01", "0x01", "0x04", "0x05", "0x00",
@@ -219,7 +219,7 @@ var Pers_util = {
for (var i = 0; i < der_header_md5.length; i++) {
header_str += String.fromCharCode(parseInt(der_header_md5[i],16));
}
- return window.btoa(header_str + base_str);
+ return window.btoa(encodeURIComponent(header_str + base_str));
},
diff --git a/plugin/chrome/content/preferences_dialog.xul b/plugin/chrome/content/preferences_dialog.xul
index 231c147..0e59ec3 100644
--- a/plugin/chrome/content/preferences_dialog.xul
+++ b/plugin/chrome/content/preferences_dialog.xul
@@ -216,5 +216,4 @@
<script type="application/x-javascript" src="preferences_dialog.js"></script>
<script type="application/x-javascript" src="common.js" ></script>
- <script type="application/x-javascript" src="base64.js" ></script>
</prefwindow>
diff --git a/plugin/chrome/content/statusbar.xul b/plugin/chrome/content/statusbar.xul
index a4392d5..080a392 100644
--- a/plugin/chrome/content/statusbar.xul
+++ b/plugin/chrome/content/statusbar.xul
@@ -9,7 +9,6 @@
</stringbundleset>
<script type="application/x-javascript" src="common.js"/>
- <script type="application/x-javascript" src="base64.js" />
<script type="application/x-javascript" src="client_policy.js" />
<script type="application/x-javascript" src="xml_notary_client.js" />
<script type="application/x-javascript" src="generate_svg.js" />
diff --git a/test/test.html b/test/test.html
index 9bccacd..a0c6cdd 100644
--- a/test/test.html
+++ b/test/test.html
@@ -6,7 +6,6 @@
<!-- Include every file so we can verify that all of the objects are testable in meta_test() -->
<script type="text/javascript" src="../about.js" ></script>
-<script type="text/javascript" src="../base64.js" ></script>
<script type="text/javascript" src="../client_policy.js" ></script>
<script type="text/javascript" src="../common.js" ></script>
<script type="text/javascript" src="../generate_svg.js" ></script>
@@ -59,7 +58,6 @@
<script type="text/javascript" src="../plugin/defaults/preferences/prefs.js" ></script>
<script type="text/javascript" src="../plugin/chrome/content/about.js" ></script>
-<script type="text/javascript" src="../plugin/chrome/content/base64.js" ></script>
<script type="text/javascript" src="../plugin/chrome/content/client_policy.js" ></script>
<script type="text/javascript" src="../plugin/chrome/content/common.js" ></script>
<script type="text/javascript" src="../plugin/chrome/content/generate_svg.js" ></script>
@@ -176,7 +174,6 @@ function meta_tests() {
var objs =
[ "Pers_about"
- , "Pers_Base64"
, "Pers_client_policy"
, "Pers_debug"
, "Pers_util"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/perspectives-extension.git
More information about the Pkg-mozext-commits
mailing list