Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:20
jsx
jsx_parser-more-strict-calendar-datetime-and-er...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File jsx_parser-more-strict-calendar-datetime-and-erlang-.patch of Package jsx
From 188fb92c357a4c57932bda58c07b69136195a6ed Mon Sep 17 00:00:00 2001 From: Led <ledest@gmail.com> Date: Sun, 29 Oct 2017 18:54:17 +0200 Subject: [PATCH] jsx_parser: more strict calendar:datetime() and erlang:timestamp() matching --- src/jsx_parser.erl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/jsx_parser.erl b/src/jsx_parser.erl index ca341c0..a012f2e 100644 --- a/src/jsx_parser.erl +++ b/src/jsx_parser.erl @@ -109,7 +109,8 @@ value([Number|Tokens], Handler, Stack, Config) when is_float(Number) -> maybe_done(Tokens, handle_event({float, Number}, Handler, Config), Stack, Config); value([{raw, Raw}|Tokens], Handler, Stack, Config) when is_binary(Raw) -> value((jsx:decoder(?MODULE, [], []))(Raw) ++ Tokens, Handler, Stack, Config); -value([{_,_,_}=Timestamp|Tokens], Handler, Stack, Config) -> +value([{MS, S, US} = Timestamp|Tokens], Handler, Stack, Config) +when is_integer(MS), is_integer(S), is_integer(US) -> {{Year, Month, Day}, {Hour, Min, Sec}} = calendar:now_to_datetime( Timestamp), value([{string, unicode:characters_to_binary(io_lib:format( @@ -121,7 +122,9 @@ value([{_,_,_}=Timestamp|Tokens], Handler, Stack, Config) -> Config ); value([{{Year, Month, Day}, {Hour, Min, Sec}}|Tokens], Handler, Stack, Config) -when is_integer(Year), is_integer(Month), is_integer(Day), is_integer(Hour), is_integer(Min), is_integer(Sec) -> +when is_integer(Year), is_integer(Month), is_integer(Day), + is_integer(Hour), is_integer(Min), is_integer(Sec), + Month >= 1, Month =< 12, Day >= 1, Day =< 31 -> value([{string, unicode:characters_to_binary(io_lib:format( "~4.10.0B-~2.10.0B-~2.10.0BT~2.10.0B:~2.10.0B:~2.10.0BZ", [Year, Month, Day, Hour, Min, Sec] @@ -131,7 +134,9 @@ when is_integer(Year), is_integer(Month), is_integer(Day), is_integer(Hour), is_ Config ); value([{{Year, Month, Day}, {Hour, Min, Sec}}|Tokens], Handler, Stack, Config) -when is_integer(Year), is_integer(Month), is_integer(Day), is_integer(Hour), is_integer(Min), is_float(Sec) -> +when is_integer(Year), is_integer(Month), is_integer(Day), + is_integer(Hour), is_integer(Min), is_float(Sec), + Month >= 1, Month =< 12, Day >= 1, Day =< 31 -> value([{string, unicode:characters_to_binary(io_lib:format( "~4.10.0B-~2.10.0B-~2.10.0BT~2.10.0B:~2.10.0B:~9.6.0fZ", [Year, Month, Day, Hour, Min, Sec] -- 2.14.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor