[Pkg-mozext-commits] [requestpolicy] 195/257: [fix] oldrules: handle URIs without host correctly
David Prévot
taffit at moszumanska.debian.org
Thu Jan 28 03:20:12 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit 3bf8a883a643b0c1d3d25288d8bfa22059638c5b
Author: Martin Kimmerle <dev at 256k.de>
Date: Sun Dec 6 00:01:30 2015 +0100
[fix] oldrules: handle URIs without host correctly
see
https://github.com/RequestPolicyContinued/requestpolicy/issues/354#issuecomment-104929274
---
src/content/lib/old-rules.jsm | 8 +++++---
tests/xpcshell/test_oldrules.js | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/src/content/lib/old-rules.jsm b/src/content/lib/old-rules.jsm
index 8c69059..9eedb21 100644
--- a/src/content/lib/old-rules.jsm
+++ b/src/content/lib/old-rules.jsm
@@ -136,10 +136,12 @@ var OldRules = (function() {
var spec = {};
if (DomainUtil.isValidUri(aEndpointString)) {
let uriObj = DomainUtil.getUriObject(aEndpointString);
- spec.h = uriObj.host;
spec.s = uriObj.scheme;
- if (uriObj.port !== -1) {
- spec.port = uriObj.port;
+ if (DomainUtil.uriObjHasHost(uriObj)) {
+ spec.h = uriObj.host;
+ if (uriObj.port !== -1) {
+ spec.port = uriObj.port;
+ }
}
} else {
spec.h = aEndpointString.split("/")[0];
diff --git a/tests/xpcshell/test_oldrules.js b/tests/xpcshell/test_oldrules.js
index 0ff7fb8..ebc8995 100644
--- a/tests/xpcshell/test_oldrules.js
+++ b/tests/xpcshell/test_oldrules.js
@@ -11,9 +11,13 @@ function run_test() {
"use strict";
test_0();
+ test_1();
}
+/**
+ * Usual rulues.
+ */
function test_0() {
"use strict";
@@ -84,6 +88,36 @@ function test_0() {
}
+/**
+ * Rules where the URIs don't have an "authority" part.
+ */
+function test_1() {
+ "use strict";
+
+ testGetOldRulesAsNewRules(
+ [
+ "foo1: " +
+ "foo2:",
+
+ "foo3: " +
+ "foo4:",
+
+ "foo5o:|foo5d: " +
+ "foo6o:|foo6d:"
+ ],
+ [
+ {o: {s: "foo1"}},
+ {o: {s: "foo2"}},
+
+ {d: {s: "foo3"}},
+ {d: {s: "foo4"}},
+
+ {o: {s: "foo5o"}, d: {s: "foo5d"}},
+ {o: {s: "foo6o"}, d: {s: "foo6d"}}
+ ]);
+}
+
+
function usingOldRulePrefs(aPrefs, aFunction) {
"use strict";
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list