Skip to content

Commit 49fd822

Browse files
committed
Merge branch 'develop'
2 parents c1290b9 + 869f8ec commit 49fd822

File tree

5 files changed

+90
-7
lines changed

5 files changed

+90
-7
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Version 1.0.3 (2014-06-27)
2+
--------------------------
3+
Changed Base64 encoding function to prevent character encoding errors, thanks @shermozle! (#231)
4+
15
Version 1.0.2 (2014-06-24)
26
--------------------------
37
Added guard to prevent document size field from being set as "NaNxNaN" (#220)

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "snowplow-tracker",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"devDependencies": {
55
"grunt": "~0.4.2",
66
"intern": "~1.4.0",
@@ -14,7 +14,6 @@
1414
"grunt-browserify": "~1.3.0",
1515
"jstimezonedetect": "~1.0.5",
1616
"JSON": "~1.0.0",
17-
"Base64": "~0.2.0",
1817
"sha1": "git://github.com/pvorb/node-sha1.git#v1.0.0",
1918
"grunt-lodash": "~0.3.0"
2019
},

src/js/lib/base64.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright (c) 2013 Kevin van Zonneveld (http://kvz.io)
3+
* and Contributors (http://phpjs.org/authors)
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
* this software and associated documentation files (the "Software"), to deal in
7+
* the Software without restriction, including without limitation the rights to
8+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9+
* of the Software, and to permit persons to whom the Software is furnished to do
10+
* so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in all
13+
* copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
* SOFTWARE.
22+
*/
23+
24+
(function() {
25+
26+
var object = typeof exports !== 'undefined' ? exports : this; // For eventual node.js environment support
27+
28+
function base64_encode(data) {
29+
// discuss at: http://phpjs.org/functions/base64_encode/
30+
// original by: Tyler Akins (http://rumkin.com)
31+
// improved by: Bayron Guevara
32+
// improved by: Thunder.m
33+
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
34+
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
35+
// improved by: Rafał Kukawski (http://kukawski.pl)
36+
// bugfixed by: Pellentesque Malesuada
37+
// example 1: base64_encode('Kevin van Zonneveld');
38+
// returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
39+
// example 2: base64_encode('a');
40+
// returns 2: 'YQ=='
41+
// example 3: base64_encode('✓ à la mode');
42+
// returns 3: '4pyTIMOgIGxhIG1vZGU='
43+
44+
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
45+
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
46+
ac = 0,
47+
enc = '',
48+
tmp_arr = [];
49+
50+
if (!data) {
51+
return data;
52+
}
53+
54+
data = unescape(encodeURIComponent(data));
55+
56+
do {
57+
// pack three octets into four hexets
58+
o1 = data.charCodeAt(i++);
59+
o2 = data.charCodeAt(i++);
60+
o3 = data.charCodeAt(i++);
61+
62+
bits = o1 << 16 | o2 << 8 | o3;
63+
64+
h1 = bits >> 18 & 0x3f;
65+
h2 = bits >> 12 & 0x3f;
66+
h3 = bits >> 6 & 0x3f;
67+
h4 = bits & 0x3f;
68+
69+
// use hexets to index into b64, and append result to encoded string
70+
tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
71+
} while (i < data.length);
72+
73+
enc = tmp_arr.join('');
74+
75+
var r = data.length % 3;
76+
77+
return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
78+
}
79+
80+
object.base64encode = base64_encode;
81+
82+
}());

src/js/payload.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@
3737
var
3838
lodash = require('./lib/lodash'),
3939
json2 = require('JSON'),
40-
Base64 = require('Base64'),
41-
base64encode = Base64.btoa,
42-
base64decode = Base64.atob,
40+
base64 = require('./lib/base64'),
4341

4442
object = typeof exports !== 'undefined' ? exports : this; // For eventual node.js environment support
4543

@@ -51,7 +49,7 @@
5149
function base64urlencode(data) {
5250
if (!data) return data;
5351

54-
var enc = base64encode(data);
52+
var enc = base64.base64encode(data);
5553
return enc.replace(/=/g, '')
5654
.replace(/\+/g, '-')
5755
.replace(/\//g, '_');

src/js/snowplow.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
windowAlias = window,
8989

9090
/* Tracker identifier with version */
91-
version = 'js-1.0.2', // Update banner.js too
91+
version = 'js-1.0.3',
9292

9393
/* Contains three variables that are shared with tracker.js and must be passed by reference */
9494
mutSnowplowState = {

0 commit comments

Comments
 (0)