Bug 1485340 - Avoid isdigit() and isxdigit() in URL parsing. r=valentin

MozReview-Commit-ID: 13DUMcZIE19

Differential Revision: https://phabricator.services.mozilla.com/D4308

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Henri Sivonen 2018-08-27 09:12:25 +00:00
parent 8330d51c91
commit 2be0158cae

View File

@ -26,6 +26,7 @@
#include "prprf.h" #include "prprf.h"
#include "nsReadableUtils.h" #include "nsReadableUtils.h"
#include "mozilla/net/MozURL_ffi.h" #include "mozilla/net/MozURL_ffi.h"
#include "mozilla/TextUtils.h"
// //
// setenv MOZ_LOG nsStandardURL:5 // setenv MOZ_LOG nsStandardURL:5
@ -435,10 +436,10 @@ ParseIPv4Number(const nsACString& input, int32_t base, uint32_t& number, uint32_
for (; current < end; ++current) { for (; current < end; ++current) {
value *= base; value *= base;
char c = *current; char c = *current;
MOZ_ASSERT((base == 10 && isdigit(c)) || MOZ_ASSERT((base == 10 && IsAsciiDigit(c)) ||
(base == 8 && c >= '0' && c <= '7') || (base == 8 && c >= '0' && c <= '7') ||
(base == 16 && isxdigit(c))); (base == 16 && IsAsciiHexDigit(c)));
if (isdigit(c)) { if (IsAsciiDigit(c)) {
value += c - '0'; value += c - '0';
} else if (c >= 'a' && c <= 'f') { } else if (c >= 'a' && c <= 'f') {
value += c - 'a' + 10; value += c - 'a' + 10;