diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-07-09 07:21:27 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-02-25 19:52:31 +0900 |
commit | 1758eade579c91f9ad000943994fccf30c7bf8a0 (patch) | |
tree | 21d9d96c0e602523b420144cc8a7e8fcfdc92789 /ext/date/date_parse.c | |
parent | d54a3df2e53a964c8bb36b87bc10ba2512830a60 (diff) |
[ruby/date] Anchor at beginning of numbers
https://hackerone.com/reports/1254844
https://github.com/ruby/date/commit/7ffe25e458
Diffstat (limited to 'ext/date/date_parse.c')
-rw-r--r-- | ext/date/date_parse.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c index 021df3793b..9511bedf47 100644 --- a/ext/date/date_parse.c +++ b/ext/date/date_parse.c @@ -253,6 +253,8 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc) #define ABBR_DAYS "sun|mon|tue|wed|thu|fri|sat" #define ABBR_MONTHS "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec" +#define NUMBER "(?<!\\d)\\d" + #ifdef TIGHT_PARSER #define VALID_DAYS "(?:" DAYS ")" "|(?:tues|wednes|thurs|thur|" ABBR_DAYS ")\\.?" #define VALID_MONTHS "(?:" MONTHS ")" "|(?:sept|" ABBR_MONTHS ")\\.?" @@ -652,7 +654,7 @@ parse_time(VALUE str, VALUE hash) { static const char pat_source[] = "(" - "\\d+\\s*" + "" NUMBER "+\\s*" "(?:" "(?:" ":\\s*\\d+" @@ -836,7 +838,7 @@ parse_eu(VALUE str, VALUE hash) FPW_COM FPT_COM #endif #ifndef TIGHT_PARSER - "('?\\d+)[^-\\d\\s]*" + "('?" NUMBER "+)[^-\\d\\s]*" #else "(\\d+)(?:(?:st|nd|rd|th)\\b)?" #endif @@ -1332,7 +1334,7 @@ parse_vms11(VALUE str, VALUE hash) { static const char pat_source[] = #ifndef TIGHT_PARSER - "('?-?\\d+)-(" ABBR_MONTHS ")[^-/.]*" + "('?-?" NUMBER "+)-(" ABBR_MONTHS ")[^-/.]*" "-('?-?\\d+)" #else BOS @@ -1427,7 +1429,7 @@ parse_sla(VALUE str, VALUE hash) { static const char pat_source[] = #ifndef TIGHT_PARSER - "('?-?\\d+)/\\s*('?\\d+)(?:\\D\\s*('?-?\\d+))?" + "('?-?" NUMBER "+)/\\s*('?\\d+)(?:\\D\\s*('?-?\\d+))?" #else BOS FPW_COM FPT_COM @@ -1535,7 +1537,7 @@ parse_dot(VALUE str, VALUE hash) { static const char pat_source[] = #ifndef TIGHT_PARSER - "('?-?\\d+)\\.\\s*('?\\d+)\\.\\s*('?-?\\d+)" + "('?-?" NUMBER "+)\\.\\s*('?\\d+)\\.\\s*('?-?\\d+)" #else BOS FPW_COM FPT_COM @@ -1695,7 +1697,7 @@ parse_mday(VALUE str, VALUE hash) { static const char pat_source[] = #ifndef TIGHT_PARSER - "(\\d+)(st|nd|rd|th)\\b" + "(" NUMBER "+)(st|nd|rd|th)\\b" #else BOS FPW_COM FPT_COM @@ -1933,7 +1935,7 @@ parse_ddd(VALUE str, VALUE hash) #ifdef TIGHT_PARSER BOS #endif - "([-+]?)(\\d{2,14})" + "([-+]?)(" NUMBER "{2,14})" "(?:" "\\s*" "t?" |