-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
YAML fixes #4838
Closed
Closed
YAML fixes #4838
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
d55225d
Make YAML behave like the YAML 1.1 spec, fixes #3101, fixes #4384, an…
jwaldrip f3c89b4
make suggested changes
jwaldrip b607b65
update from_yaml to match the changes in to_yaml
jwaldrip b6a2e09
reserved values performance
jwaldrip f14198b
raise with a location
jwaldrip 8346108
add todo
jwaldrip 016dfd4
format
jwaldrip d6886fc
use case
jwaldrip d11fd05
Merge branch 'master' of https://github.com/crystal-lang/crystal into…
jwaldrip 1bc96b5
use a char reader to give hints
jwaldrip ffccba4
use a case statement testing all the reserved cases
jwaldrip de2a1b7
add date to test case
jwaldrip d2476e2
use try's
jwaldrip 922fa83
move logic into YAML::PullParser
jwaldrip 47ee91c
use the method check
jwaldrip 86f3f4b
dont raise
jwaldrip 1faeb45
spelling & grammer
jwaldrip f5fc600
Merge branch 'yaml-spec' of github.com:jwaldrip/crystal into yaml-spec
jwaldrip 0c605a8
Merge branch 'master' of github.com:jwaldrip/crystal into yaml-spec
jwaldrip cf95b76
re-inline specs
jwaldrip 5a90882
remove checks
jwaldrip b3f6436
make suggested changes
jwaldrip 3157fab
more spec changes
jwaldrip ceb9db9
fix quoted spec
jwaldrip e3df0d6
inline bool checks
jwaldrip 50d5705
return false, remove parens
jwaldrip e2c8a1a
Merge branch 'master' of https://github.com/crystal-lang/crystal into…
jwaldrip 69ee625
make `YAML.parse` support the core spec
jwaldrip 31ca301
Merge branch 'yaml-spec' of github.com:jwaldrip/crystal into yaml-spec
jwaldrip 6a5b820
Merge branch 'master' of https://github.com/crystal-lang/crystal into…
jwaldrip 7a36cdc
Merge branch 'master' of https://github.com/crystal-lang/crystal into…
jwaldrip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,18 +168,17 @@ module YAML | |
# Checks to see if the value is reserved | ||
def self.reserved_value?(value) | ||
return true if YAML::RESERVED_VALUES.includes?(value) | ||
reserved = case {value[0]?, value[1]?, value[2]?, value[3]?, value[4]?} | ||
when {.try(&.ascii_number?), .try(&.ascii_number?), .try(&.ascii_number?), .try(&.ascii_number?), '-'} | ||
(Time::Format::ISO_8601_DATE_TIME.parse(value) rescue false) | ||
when {.try(&.ascii_number?), _, _, _, _}, | ||
{'-', .try(&.ascii_number?), _, _, _}, | ||
{'+', .try(&.ascii_number?), _, _, _}, | ||
{'.', .try(&.ascii_number?), _, _, _}, | ||
{'-', '.', .try(&.ascii_number?), _, _}, | ||
{'+', '.', .try(&.ascii_number?), _, _} | ||
clean_value = value.gsub('_', "") | ||
clean_value.to_f64? || clean_value.to_i64?(prefix: true) | ||
end | ||
!reserved.nil? | ||
case {value[0]?, value[1]?, value[2]?, value[3]?, value[4]?} | ||
when {.try(&.ascii_number?), .try(&.ascii_number?), .try(&.ascii_number?), .try(&.ascii_number?), '-'} | ||
!!(Time::Format::ISO_8601_DATE_TIME.parse(value) rescue false) | ||
when {.try(&.ascii_number?), _, _, _, _}, | ||
{'-', .try(&.ascii_number?), _, _, _}, | ||
{'+', .try(&.ascii_number?), _, _, _}, | ||
{'.', .try(&.ascii_number?), _, _, _}, | ||
{'-', '.', .try(&.ascii_number?), _, _}, | ||
{'+', '.', .try(&.ascii_number?), _, _} | ||
clean_value = value.gsub('_', "") | ||
!!clean_value.to_f64? || !!clean_value.to_i64?(prefix: true) | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method should return |
||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parenthesis should not be needed here, because
false
is a Bool anyway