corner case in Text.JSON 0.4.3

hi, since i got no answer from the maintainer, maybe someone else can take care of it, or at least point out, what i did wrong. so, i recently stumbled upon some error while using Text.JSON 0.4.3 [1]: Text/JSON/String.hs:(127,4)-(137,49): Non-exhaustive patterns in case indeed ghc warned: [5 of 7] Compiling Text.JSON.String ( Text/JSON/String.hs, dist/build/Text/JSON/String.o ) Text/JSON/String.hs:127:4: Warning: Pattern match(es) are non-exhaustive In a case alternative: Patterns not matched: [] from looking at the code i couldn't see how this would ever happen, but you can reproduce it be running the files from [2]: $ ./test < problem Ok (JSArray [JSString (JSONString {fromJSString = "this"}),JSString (JSONString {fromJSString = "is"}),JSString (JSONString {fromJSString = "some"}),JSString (JSONString {fromJSString = "json"}),JSObject (JSONObject {fromJSObject = [("that",JSString (JSONString {fromJSString = "works"}))]})]) test: Text/JSON/String.hs:(127,4)-(137,49): Non-exhaustive patterns in case the patch i put there fixes it (at least for me) to return an Error instead of dying: $ ./test < problem Ok (JSArray [JSString (JSONString {fromJSString = "this"}),JSString (JSONString {fromJSString = "is"}),JSString (JSONString {fromJSString = "some"}),JSString (JSONString {fromJSString = "json"}),JSObject (JSONObject {fromJSObject = [("that",JSString (JSONString {fromJSString = "works"}))]})]) Error "Unexpected end of String: does" Error "Malformed JSON: invalid token in this context not\"]" test: <stdin>: hGetLine: end of file have fun martin hilbig [1]: http://hackage.haskell.org/package/json [2]: http://friendpaste.com/3IvnChRMoczf0mIKpOtrYE

Hi,
I think it was probably I who wrote this, so I'll take the blame :-)
It seems like a genuine bug, where we are not checking for strings
that are not terminated. Thanks for spotting it, and also for the
patch! I'll try to update the package soon.
-Iavor
On Wed, May 12, 2010 at 12:53 PM, Martin Hilbig
hi,
since i got no answer from the maintainer, maybe someone else can take care of it, or at least point out, what i did wrong.
so, i recently stumbled upon some error while using Text.JSON 0.4.3 [1]:
Text/JSON/String.hs:(127,4)-(137,49): Non-exhaustive patterns in case
indeed ghc warned:
[5 of 7] Compiling Text.JSON.String ( Text/JSON/String.hs, dist/build/Text/JSON/String.o )
Text/JSON/String.hs:127:4: Warning: Pattern match(es) are non-exhaustive In a case alternative: Patterns not matched: []
from looking at the code i couldn't see how this would ever happen, but you can reproduce it be running the files from [2]:
$ ./test < problem Ok (JSArray [JSString (JSONString {fromJSString = "this"}),JSString (JSONString {fromJSString = "is"}),JSString (JSONString {fromJSString = "some"}),JSString (JSONString {fromJSString = "json"}),JSObject (JSONObject {fromJSObject = [("that",JSString (JSONString {fromJSString = "works"}))]})]) test: Text/JSON/String.hs:(127,4)-(137,49): Non-exhaustive patterns in case
the patch i put there fixes it (at least for me) to return an Error instead of dying:
$ ./test < problem Ok (JSArray [JSString (JSONString {fromJSString = "this"}),JSString (JSONString {fromJSString = "is"}),JSString (JSONString {fromJSString = "some"}),JSString (JSONString {fromJSString = "json"}),JSObject (JSONObject {fromJSObject = [("that",JSString (JSONString {fromJSString = "works"}))]})]) Error "Unexpected end of String: does" Error "Malformed JSON: invalid token in this context not\"]" test: <stdin>: hGetLine: end of file
have fun martin hilbig
[1]: http://hackage.haskell.org/package/json [2]: http://friendpaste.com/3IvnChRMoczf0mIKpOtrYE _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Wednesday 12 May 2010 21:53:41, Martin Hilbig wrote:
hi,
since i got no answer from the maintainer, maybe someone else can take care of it, or at least point out, what i did wrong.
so, i recently stumbled upon some error while using Text.JSON 0.4.3 [1]:
Text/JSON/String.hs:(127,4)-(137,49): Non-exhaustive patterns in case
indeed ghc warned:
[5 of 7] Compiling Text.JSON.String ( Text/JSON/String.hs, dist/build/Text/JSON/String.o )
Text/JSON/String.hs:127:4: Warning: Pattern match(es) are non-exhaustive In a case alternative: Patterns not matched: []
from looking at the code i couldn't see how this would ever happen, but
readJSString will die a horrible death if the closing quote is missing. Your input misses the closing quote, so...

Hi,
it seems that this was already fixed in the repo, I've put a new
version (0.4.4) on hackage. Thanks, again, for spotting this!
-Iavor
On Wed, May 12, 2010 at 1:24 PM, Daniel Fischer
On Wednesday 12 May 2010 21:53:41, Martin Hilbig wrote:
hi,
since i got no answer from the maintainer, maybe someone else can take care of it, or at least point out, what i did wrong.
so, i recently stumbled upon some error while using Text.JSON 0.4.3 [1]:
Text/JSON/String.hs:(127,4)-(137,49): Non-exhaustive patterns in case
indeed ghc warned:
[5 of 7] Compiling Text.JSON.String ( Text/JSON/String.hs, dist/build/Text/JSON/String.o )
Text/JSON/String.hs:127:4: Warning: Pattern match(es) are non-exhaustive In a case alternative: Patterns not matched: []
from looking at the code i couldn't see how this would ever happen, but
readJSString will die a horrible death if the closing quote is missing. Your input misses the closing quote, so...
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

martin:
hi,
since i got no answer from the maintainer, maybe someone else can take care of it, or at least point out, what i did wrong.
so, i recently stumbled upon some error while using Text.JSON 0.4.3 [1]:
Text/JSON/String.hs:(127,4)-(137,49): Non-exhaustive patterns in case
indeed ghc warned:
[5 of 7] Compiling Text.JSON.String ( Text/JSON/String.hs, dist/build/Text/JSON/String.o )
Text/JSON/String.hs:127:4: Warning: Pattern match(es) are non-exhaustive In a case alternative: Patterns not matched: []
from looking at the code i couldn't see how this would ever happen, but you can reproduce it be running the files from [2]:
$ ./test < problem Ok (JSArray [JSString (JSONString {fromJSString = "this"}),JSString (JSONString {fromJSString = "is"}),JSString (JSONString {fromJSString = "some"}),JSString (JSONString {fromJSString = "json"}),JSObject (JSONObject {fromJSObject = [("that",JSString (JSONString {fromJSString = "works"}))]})]) test: Text/JSON/String.hs:(127,4)-(137,49): Non-exhaustive patterns in case
the patch i put there fixes it (at least for me) to return an Error instead of dying:
$ ./test < problem Ok (JSArray [JSString (JSONString {fromJSString = "this"}),JSString (JSONString {fromJSString = "is"}),JSString (JSONString {fromJSString = "some"}),JSString (JSONString {fromJSString = "json"}),JSObject (JSONObject {fromJSObject = [("that",JSString (JSONString {fromJSString = "works"}))]})]) Error "Unexpected end of String: does" Error "Malformed JSON: invalid token in this context not\"]" test: <stdin>: hGetLine: end of file
have fun martin hilbig
[1]: http://hackage.haskell.org/package/json [2]: http://friendpaste.com/3IvnChRMoczf0mIKpOtrYE
Send me the patch :-)

On Wed, May 12, 2010 at 10:05 PM, Don Stewart
martin:
hi,
since i got no answer from the maintainer, maybe someone else can take care of it, or at least point out, what i did wrong.
so, i recently stumbled upon some error while using Text.JSON 0.4.3 [1]:
Text/JSON/String.hs:(127,4)-(137,49): Non-exhaustive patterns in case
indeed ghc warned:
[5 of 7] Compiling Text.JSON.String ( Text/JSON/String.hs, dist/build/Text/JSON/String.o )
Text/JSON/String.hs:127:4: Warning: Pattern match(es) are non-exhaustive In a case alternative: Patterns not matched: []
from looking at the code i couldn't see how this would ever happen, but you can reproduce it be running the files from [2]:
$ ./test < problem Ok (JSArray [JSString (JSONString {fromJSString = "this"}),JSString (JSONString {fromJSString = "is"}),JSString (JSONString {fromJSString = "some"}),JSString (JSONString {fromJSString = "json"}),JSObject (JSONObject {fromJSObject = [("that",JSString (JSONString {fromJSString = "works"}))]})]) test: Text/JSON/String.hs:(127,4)-(137,49): Non-exhaustive patterns in case
the patch i put there fixes it (at least for me) to return an Error instead of dying:
$ ./test < problem Ok (JSArray [JSString (JSONString {fromJSString = "this"}),JSString (JSONString {fromJSString = "is"}),JSString (JSONString {fromJSString = "some"}),JSString (JSONString {fromJSString = "json"}),JSObject (JSONObject {fromJSObject = [("that",JSString (JSONString {fromJSString = "works"}))]})]) Error "Unexpected end of String: does" Error "Malformed JSON: invalid token in this context not\"]" test: <stdin>: hGetLine: end of file
have fun martin hilbig
[1]: http://hackage.haskell.org/package/json [2]: http://friendpaste.com/3IvnChRMoczf0mIKpOtrYE
Send me the patch :-)
I think Iavor already updated it, but I did notice that Sigbjorn is still listed as the maintainer. Don are you saying we should put your name there? Jason
participants (5)
-
Daniel Fischer
-
Don Stewart
-
Iavor Diatchki
-
Jason Dagit
-
Martin Hilbig