New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DateTime.new accepts bogus string input #4907
Comments
From zefram@fysh.orgThe documentation for DateTime.new says that when given a string input "2000-01-01T00:00:00+0000" (mixed basic and extended representations) The first two failures are specific to the timezone portion of the string. -zefram |
From @lizmat
I tend to say ENOTABUG, as they are cases of “be liberal in what you accept” and they match the regular expression. If they wouldn’t match that, *then* an exception would be thrown. $ 6 'DateTime.new("2000-01-01T00:00:00+0000").say' They all seem to generate the correct DateTime object. Note that if there is an error: $ 6 'DateTime.new("2000-01-0\x[666]T00:00:90").say' Liz |
The RT System itself - Status changed from 'new' to 'open' |
From zefram@fysh.orgElizabeth Mattijsen via RT wrote:
If the code is not a bug, then the documentation is, because it explicitly Accepts a C<Str|/type/Str> formatted as C<yyyy-mm-ddThh:mm:ssZ>
I would not say that there is any correct DateTime object to generate from -zefram |
From zefram@fysh.orgCommit 895546990f6001a5999ef, attempting to fix [perl #127004], has -zefram |
From @labsterOn Wed Dec 23 16:05:59 2015, zefram@fysh.org wrote:
http://design.perl6.org/S32/Temporal.html#line_97 says that DateTime.new accepts RFC 3339 strings, not ISO 8601. It should probably accept both. One of the "wrong" formats in particular, the timezone -0000, is required by RFC 3339. I'm pretty sure that this is a docs bug, not a rakudobug. The purpose of DateTime.new is not to validate your datetime format, it's to produce an internal representation of a date string. DateTime.new($foo).Str does produce valid and correct ISO 8601 strings, and that's good enough for me. And I imagine that most of the users will agree that we should apply Postel's law here -- so long as we document it. Any solution beyond that should go into module space. Rejecting ticket. |
@labster - Status changed from 'open' to 'rejected' |
From zefram@fysh.orgBrent Laabs via RT wrote:
If you specifically intend to accept RFC 3339 format then OK, that's
Input validation is a useful feature, and is actually being advertised by
The Postel principle doesn't properly apply here. It's a strategy In any case, this code doesn't look like intentional liberality: it's not
As I said in an earlier message, if the code is not a bug then the -zefram |
From @labsterOn Thu Dec 24 03:00:45 2015, zefram@fysh.org wrote:
I'm rejecting essentially every assertion you made in the last reply. There is no mismatch between docs and implementation (see Raku/doc@4ee960f ). There is no desire to see verification in this code, because unambiguous data should work without having to massage it into the most correct format -- the precise definition of which isn't freely available on the web. Most people want the DateTime library to be fast, not to involve extra verification steps. That "most people" doesn't mean "me" -- it's the opinion of many people who have worked on Perl 5 DateTime (c.f. DateTime::LazyInit). Your interpretation of Postel's law is incorrect, too. While the spec is clear, other implementations of the spec may have minor mistakes. Like a sign or mixing extended and condensed formats. We shouldn't feel bad about accepting those formats, no matter what you think. So long as we produce correct output (see your other tickets), we're following Postel's law. Input validation is a useful feature, but you can hardly call a parenthetical an advertisement of that feature (as it was in the older version of the docs). So I guess I disagree with you there as well. |
From zefram@fysh.orgBrent Laabs via RT wrote:
Ah, the mismatch has been resolved by that change, in response to
This argument might carry some weight if the code were actually written to
"An invalid input string throws an exception" was not parenthetical, -zefram |
Migrated from rt.perl.org#127002 (status was 'rejected')
Searchable as RT127002$
The text was updated successfully, but these errors were encountered: