Skip to content
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

Raise an error if a decode target JSON is followed by extra garbage chars. #69

Merged
merged 1 commit into from
Nov 15, 2021

Conversation

sile
Copy link
Owner

@sile sile commented Nov 15, 2021

Before

> jsone:decode(<<"1@">>).
1

After

> jsone:decode(<<"1@">>).
** exception error: bad argument
     in function  jsone:check_decode_remainings/1
        called as jsone:check_decode_remainings(<<"@">>)
     in call from jsone:decode/2 (/home/tohta/dev/erlang/jsone/src/jsone.erl, line 338)

> jsone:decode(<<"1 \n">>).  % Whitespaces are still okay
1

Resolves #68

@codecov-commenter
Copy link

Codecov Report

Merging #69 (4c24e00) into master (5b8a858) will increase coverage by 0.47%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #69      +/-   ##
==========================================
+ Coverage   91.43%   91.91%   +0.47%     
==========================================
  Files           4        4              
  Lines         327      334       +7     
==========================================
+ Hits          299      307       +8     
+ Misses         28       27       -1     
Impacted Files Coverage Δ
src/jsone.erl 82.60% <100.00%> (+13.85%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b8a858...4c24e00. Read the comment docs.

@sile sile merged commit 31e9f0e into master Nov 15, 2021
@sile sile deleted the check-garbage-chars branch November 15, 2021 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

decoding invalid JSON starting with number and followed by extra characters doesn't throw exception
2 participants