summaryrefslogtreecommitdiffstats
path: root/js/src/jsdate.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-07-10 18:46:10 +0000
committerMoonchild <moonchild@palemoon.org>2020-07-10 18:46:10 +0000
commitf1b51be787c11090c8d9b2ec73255df7a67c7eb7 (patch)
tree9c6d35ce6f19e0fef3c47c7e2c152394854cf217 /js/src/jsdate.cpp
parent2deaddfca28508ac1a634eb6088a1da8e571ec6e (diff)
parent82faff19e1761797b7a75f9221f0709c5a38bfe6 (diff)
downloadUXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.tar
UXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.tar.gz
UXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.tar.lz
UXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.tar.xz
UXP-f1b51be787c11090c8d9b2ec73255df7a67c7eb7.zip
Merge branch 'redwood' into releaseRELBASE_20200711
Diffstat (limited to 'js/src/jsdate.cpp')
-rwxr-xr-xjs/src/jsdate.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/js/src/jsdate.cpp b/js/src/jsdate.cpp
index c6a369e2d..41722ffa9 100755
--- a/js/src/jsdate.cpp
+++ b/js/src/jsdate.cpp
@@ -21,6 +21,8 @@
#include "mozilla/FloatingPoint.h"
#include "mozilla/Sprintf.h"
+#include "nsCRT.h"
+
#include <ctype.h>
#include <math.h>
#include <string.h>
@@ -958,11 +960,20 @@ ParseDate(const CharT* s, size_t length, ClippedTime* result)
while (i < length) {
int c = s[i];
i++;
- if (c <= ' ' || c == ',' || c == '-') {
- if (c == '-' && '0' <= s[i] && s[i] <= '9')
+
+ // Spaces, ASCII control characters, and commas are ignored.
+ if (c <= ' ' || c == ',')
+ continue;
+
+ // Dashes are delimiters if they're immediately followed by a number field.
+ // If they're not followed by a number field, they're simply ignored.
+ if (c == '-') {
+ if (i < length && nsCRT::IsAsciiDigit(s[i])) {
prevc = c;
+ }
continue;
}
+
if (c == '(') { /* comments) */
int depth = 1;
while (i < length) {
@@ -977,7 +988,9 @@ ParseDate(const CharT* s, size_t length, ClippedTime* result)
}
continue;
}
- if ('0' <= c && c <= '9') {
+
+ // Parse a number field.
+ if (nsCRT::IsAsciiDigit(c)) {
int n = c - '0';
while (i < length && '0' <= (c = s[i]) && c <= '9') {
n = n * 10 + c - '0';