mirror of
https://github.com/bellard/quickjs.git
synced 2025-05-15 10:45:02 +08:00
fixed date parsing in case there is more than nine initial digits (initial patch by nickva)
This commit is contained in:
parent
6e2e68fd08
commit
030333cff6
@ -50006,6 +50006,9 @@ static BOOL string_get_digits(const uint8_t *sp, int *pp, int *pval,
|
|||||||
|
|
||||||
p_start = p;
|
p_start = p;
|
||||||
while ((c = sp[p]) >= '0' && c <= '9') {
|
while ((c = sp[p]) >= '0' && c <= '9') {
|
||||||
|
/* arbitrary limit to 9 digits */
|
||||||
|
if (v >= 100000000)
|
||||||
|
return FALSE;
|
||||||
v = v * 10 + c - '0';
|
v = v * 10 + c - '0';
|
||||||
p++;
|
p++;
|
||||||
if (p - p_start == max_digits)
|
if (p - p_start == max_digits)
|
||||||
@ -50053,7 +50056,7 @@ static BOOL string_get_tzoffset(const uint8_t *sp, int *pp, int *tzp, BOOL stric
|
|||||||
sgn = sp[p++];
|
sgn = sp[p++];
|
||||||
if (sgn == '+' || sgn == '-') {
|
if (sgn == '+' || sgn == '-') {
|
||||||
int n = p;
|
int n = p;
|
||||||
if (!string_get_digits(sp, &p, &hh, 1, 9))
|
if (!string_get_digits(sp, &p, &hh, 1, 0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
n = p - n;
|
n = p - n;
|
||||||
if (strict && n != 2 && n != 4)
|
if (strict && n != 2 && n != 4)
|
||||||
@ -50245,7 +50248,7 @@ static BOOL js_date_parse_otherstring(const uint8_t *sp,
|
|||||||
*is_local = FALSE;
|
*is_local = FALSE;
|
||||||
} else {
|
} else {
|
||||||
p++;
|
p++;
|
||||||
if (string_get_digits(sp, &p, &val, 1, 9)) {
|
if (string_get_digits(sp, &p, &val, 1, 0)) {
|
||||||
if (c == '-') {
|
if (c == '-') {
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -50256,7 +50259,7 @@ static BOOL js_date_parse_otherstring(const uint8_t *sp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (string_get_digits(sp, &p, &val, 1, 9)) {
|
if (string_get_digits(sp, &p, &val, 1, 0)) {
|
||||||
if (string_skip_char(sp, &p, ':')) {
|
if (string_skip_char(sp, &p, ':')) {
|
||||||
/* time part */
|
/* time part */
|
||||||
fields[3] = val;
|
fields[3] = val;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user