Issue #13661 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Rejected

`{Date,DateTime}.parse` use a loose parsing.  They assume that somewhere in the string, there is something representing a date or time, and do their best to find it.  Only if they can find nothing related to a date or time do they raise an exception.

In this case, `mark / gmail.com` is parsed as the month `March`:

```
DateTime._parse('mark / gmail.com')
# => {:mon=>3}
```

As no year or day is given, March 1 of the current year at midnight is used.

While this loose parsing is a fairly common compliant with the methods, it isn't a bug.  As the documentation states: `This method does not function as a validator.`  You should not pass strings to `{Date,DateTime}.parse` unless you think they contain a date.

----------------------------------------
Bug #13661: DateTime.parse parses strings with a month abbreviation after a word boundary as a valid date
https://bugs.ruby-lang.org/issues/13661#change-78832

* Author: jbcden (Jacob Chae)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.4.1
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
When parsing a string like "mark / gmail.com" it parses it into a DateTime i.e.:

~~~ ruby
require 'date'
DateTime.parse('mark / gmail.com')
#=> #<DateTime: 2017-03-01T00:00:00+00:00 ((2457814j,0s,0n),+0s,2299161j)>
~~~

It seems like https://github.com/ruby/ruby/blob/9c9c46e5a30fb47068337932eefde759b2763551/ext/date/date_parse.c#L1612 is the source of the issue. I think this might just require a slight tweak of the regex, it looks like things like "test.mark / gmail.com" work but not "testmark / gmail.com".




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>