Skip to content

Commit 59379a1

Browse files
author
Peter Eckersley
committed
Unstable starts as a copy of stable.
svn:r110
1 parent e3aec08 commit 59379a1

33 files changed

+2930
-0
lines changed

makexpi.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
APP_NAME=https-everywhere
3+
VERSION=`grep em:version src/install.rdf | sed -e 's/[<>]/ /g' | cut -f3`
4+
XPI_NAME=$APP_NAME-$VERSION.xpi
5+
6+
if [ -e "pkg/$XPI_NAME" ]; then
7+
echo pkg/$XPI_NAME already exists.
8+
rm pkg/$XPI_NAME # meh.
9+
# exit 1
10+
fi
11+
12+
# create jar file (we're just storing files here)
13+
echo ---------- create $APP_NAME.jar file ----------
14+
cd src/chrome
15+
#zip -r0 ../../$APP_NAME.jar ./ -x "*.svn/*"
16+
cd ../..
17+
18+
# create .xpi
19+
echo ---------- create $APP_NAME.xpi ----------
20+
cd src
21+
echo zip -X -9r ../pkg/$XPI_NAME ./ -x "certDialogsOverride.js" -x "chrome/*" -x "*.diff" -x "*.svn/*" -x ".*.sw?"
22+
zip -X -9r ../pkg/$XPI_NAME ./ -x "*.svn/*" -x "*.diff" -x "*.swp" #-x "chrome/*"
23+
#mv ../$APP_NAME.jar ./chrome
24+
#zip -9m ../pkg/$XPI_NAME chrome/$APP_NAME.jar
25+
cd ..
26+
27+
#cp ./pkg/$XPI_NAME ~/
28+
#zip -9m ../../downloads/$sXpiName chrome/$APP_NAME.jar
29+
#zip -9 ../../downloads/$sXpiName install.rdf
30+
#cd ..

src/LICENSE.txt

Lines changed: 364 additions & 0 deletions
Large diffs are not rendered by default.

src/chrome.manifest

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
content https-everywhere chrome/content/
2+
3+
locale https-everywhere en chrome/locale/en/
4+
5+
skin https-everywhere classic/1.0 chrome/skin/

src/chrome/content/code/Cookie.js

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
function Cookie(s, host) {
2+
this.parse(s, host);
3+
}
4+
Cookie.computeId = function(c) {
5+
return c.name + ";" + c.host + "/" + c.path;
6+
};
7+
Cookie.find = function(f) {
8+
var cc = Cookie.prototype.cookieManager.enumerator;
9+
var c;
10+
while (cc.hasMoreElements()) {
11+
if (f(c = cc.getNext())) return c;
12+
}
13+
return null;
14+
};
15+
16+
Cookie.attributes = { host: 'domain', path: 'path', expires: 'expires', isHttpOnly: 'HttpOnly', isSecure: 'Secure' };
17+
Cookie.prototype = {
18+
19+
name: '',
20+
value: '',
21+
source: '',
22+
domain: '',
23+
host: '',
24+
rawHost: '',
25+
path: '',
26+
secure: false,
27+
httponly: false,
28+
session: true,
29+
expires: 0,
30+
31+
id: '',
32+
33+
34+
toString: function() {
35+
var c = [this['name'] + "=" + this.value];
36+
var v;
37+
const aa = Cookie.attributes;
38+
for (var k in aa) {
39+
var p = aa[k];
40+
v = this[k];
41+
switch(typeof(v)) {
42+
case "string":
43+
if (v) c.push(p + "=" + v);
44+
break;
45+
case "boolean":
46+
if (v) c.push(p);
47+
break;
48+
case "number":
49+
if (!this.isSession) c.push(p + "=" + new Date(v * 1000).toUTCString());
50+
break;
51+
}
52+
}
53+
return c.join("; ");
54+
},
55+
parse: function(s, host) {
56+
var p;
57+
if (this.source) {
58+
// cleanup for recycle
59+
for (p in this) {
60+
if (typeof (p) != "function") delete this[p];
61+
}
62+
}
63+
this.source = s;
64+
this.host = host;
65+
66+
var parts = s.split(/;\s*/);
67+
var nv = parts.shift().split("=");
68+
69+
this.name = nv.shift() || '';
70+
this.value = nv.join('=') || '';
71+
72+
var n, v;
73+
for each (p in parts) {
74+
nv = p.split("=");
75+
switch (n = nv[0].toLowerCase()) {
76+
case 'expires':
77+
v = Math.round(Date.parse((nv[1] || '').replace(/\-/g, ' ')) / 1000);
78+
break;
79+
case 'domain':
80+
case 'path':
81+
v = nv[1] || '';
82+
break;
83+
case 'secure':
84+
case 'httponly':
85+
v = true;
86+
break;
87+
default:
88+
n = 'unknown'
89+
}
90+
this[n] = v;
91+
}
92+
if (!this.expires) {
93+
this.session = true;
94+
this.expires = Math.round(new Date() / 1000) + 31536000;
95+
}
96+
if (this.domain) {
97+
if (!this.isDomain) this.domain = "." + this.domain;
98+
this.host = this.domain;
99+
}
100+
this.rawHost = this.host.replace(/^\./, '');
101+
102+
this.id = Cookie.computeId(this);
103+
},
104+
105+
106+
get cookieManager() {
107+
delete Cookie.prototype.cookieManager;
108+
var cman = CC["@mozilla.org/cookiemanager;1"]
109+
.getService(CI.nsICookieManager2).QueryInterface(CI.nsICookieManager);
110+
return Cookie.prototype.cookieManager = cman;
111+
},
112+
belongsTo: function(host, path) {
113+
if (path && this.path && path.indexOf(this.path) != 0) return false;
114+
if (host == this.rawHost) return true;
115+
var d = this.domain;
116+
return d && (host == d || this.isDomain && host.slice(-d.length) == d);
117+
},
118+
save: function() {
119+
this.save = ("cookieExists" in this.cookieManager)
120+
? function() { this.cookieManager.add(this.host, this.path, this.name, this.value, this.secure, this.httponly, this.session, this.expires); }
121+
: function() { this.cookieManager.add(this.host, this.path, this.name, this.value, this.secure, this.session, this.expires);}
122+
;
123+
return this.save();
124+
},
125+
exists: function() {
126+
var cc = this.cookieManager.enumerator;
127+
while(cc.hasMoreElements()) {
128+
if (this.sameAs(cc.getNext())) return true;
129+
}
130+
return false;
131+
},
132+
133+
sameAs: function(c) {
134+
(c instanceof CI.nsICookie) && (c instanceof CI.nsICookie2);
135+
return Cookie.computeId(c) == this.id;
136+
},
137+
138+
// nsICookie2 interface extras
139+
get isSecure() { return this.secure; },
140+
get expiry() { return this.expires; },
141+
get isSession() { return this.session; },
142+
get isHttpOnly() { return this.httponly; },
143+
get isDomain() { return this.domain && this.domain[0] == '.'; },
144+
policy: 0,
145+
status: 0,
146+
QueryInterface: xpcom_generateQI([CI.nsICookie, CI.nsICookie2, CI.nsISupports])
147+
148+
}

0 commit comments

Comments
 (0)