[Pkg-mozext-commits] [requestpolicy] 267/280: Use `DomainUtil.isIPAddress()` in `ruleset.jsm`

David Prévot taffit at moszumanska.debian.org
Sat May 2 20:30:37 UTC 2015


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

taffit pushed a commit to branch master
in repository requestpolicy.

commit 0d802ecaa29fff9ad5bbd0a064cb08ff8854d2fa
Author: Martin Kimmerle <dev at 256k.de>
Date:   Thu Apr 30 12:59:46 2015 +0200

    Use `DomainUtil.isIPAddress()` in `ruleset.jsm`
    
    The `Ruleset` class in `ruleset.jsm` had the function
    `_isIPAddress()`, which had a bug. As there is already another
    function doing the same (`DomainUtil.isIPAddress()`), that
    function is now used and `Ruleset`'s function has been removed.
---
 src/content/lib/ruleset.jsm | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/src/content/lib/ruleset.jsm b/src/content/lib/ruleset.jsm
index ff7fac1..b35bc34 100644
--- a/src/content/lib/ruleset.jsm
+++ b/src/content/lib/ruleset.jsm
@@ -780,24 +780,6 @@ Ruleset.prototype = {
     this.rules.print(depth + 1);
   },
 
-  // fixme: this static function should be `Ruleset.isIPAddress()`
-  /**
-   * @static
-   */
-  _isIPAddress : function(host) {
-    // Check if it's an IPv6 address.
-    if (host.indexOf(":") != -1) {
-      return true;
-    }
-    var parts = host.split(".");
-    for (var i = 0; i < parts.length; i++) {
-      if (!parseInt(parts[i])) {
-        return false;
-      }
-    }
-    return true;
-  },
-
   _getIPAddress : function(address) {
     // TODO: Canonicalize IPv6 addresses.
     return this._ipAddr[address];
@@ -851,7 +833,7 @@ Ruleset.prototype = {
     if (!host) {
       throw "INVALID_HOST";
     }
-    if (this._isIPAddress(host)) {
+    if (DomainUtil.isIPAddress(host)) {
       return this._getIPAddress(host);
     } else {
       return this._getDomain(host);
@@ -862,7 +844,7 @@ Ruleset.prototype = {
     if (!host) {
       throw "INVALID_HOST";
     }
-    if (this._isIPAddress(host)) {
+    if (DomainUtil.isIPAddress(host)) {
       return this._addIPAddress(host);
     } else {
       return this._addDomain(host);
@@ -893,7 +875,7 @@ Ruleset.prototype = {
       return;
     }
 
-    if (this._isIPAddress(host)) {
+    if (DomainUtil.isIPAddress(host)) {
       var addrEntry = this._ipAddr[host];
       if (addrEntry) {
         yield addrEntry;

-- 
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