Bug 1485340 - Avoid isdigit() and isxdigit() in URL parsing. r=valentin
authorHenri Sivonen <hsivonen@hsivonen.fi>
Mon, 27 Aug 2018 09:12:25 +0000
changeset 433454 be9a8690948707b0e965c0e47198018c47b35fe5
parent 433453 a8af113596e48a8aeff574a814976df5c3753f0c
child 433455 4095afaecf59f6296e72102c4aefc6c54b7305e5
push id34514
push usercsabou@mozilla.com
push dateMon, 27 Aug 2018 15:50:26 +0000
treeherdermozilla-central@c417b2354667 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1485340
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1485340 - Avoid isdigit() and isxdigit() in URL parsing. r=valentin MozReview-Commit-ID: 13DUMcZIE19 Differential Revision: https://phabricator.services.mozilla.com/D4308
netwerk/base/nsStandardURL.cpp
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -21,16 +21,17 @@
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "mozilla/TextUtils.h"
 #include <algorithm>
 #include "nsContentUtils.h"
 #include "prprf.h"
 #include "nsReadableUtils.h"
 #include "mozilla/net/MozURL_ffi.h"
+#include "mozilla/TextUtils.h"
 
 //
 // setenv MOZ_LOG nsStandardURL:5
 //
 static LazyLogModule gStandardURLLog("nsStandardURL");
 
 // The Chromium code defines its own LOG macro which we don't want
 #undef LOG
@@ -430,20 +431,20 @@ ParseIPv4Number(const nsACString& input,
         break;
       case 10:
       default:
         break;
     }
     for (; current < end; ++current) {
         value *= base;
         char c = *current;
-        MOZ_ASSERT((base == 10 && isdigit(c)) ||
+        MOZ_ASSERT((base == 10 && IsAsciiDigit(c)) ||
                    (base == 8 && c >= '0' && c <= '7') ||
-                   (base == 16 && isxdigit(c)));
-        if (isdigit(c)) {
+                   (base == 16 && IsAsciiHexDigit(c)));
+        if (IsAsciiDigit(c)) {
             value += c - '0';
         } else if (c >= 'a' && c <= 'f') {
             value += c - 'a' + 10;
         } else if (c >= 'A' && c <= 'F') {
             value += c - 'A' + 10;
         }
     }