Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the TOML CPAN distribution.

Report information
The Basics
Id: 83836
Status: resolved
Priority: 0/
Queue: TOML

People
Owner: darren [...] cpan.org
Requestors: MBETHKE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.9
Fixed in: 0.91



Subject: Malformed strings send parser into an endless loop
If e.g. the user misquotes a value as foo = "bar' the parser gets stuck in an endless loop. Minimal example: perl -MTOML -E'say "ok" if from_toml("foo = \"bar'"'"'")' This is because you assume that one of the s/// regexes for the various constructs wil always match and thus shorten the string, but this syntax error (and a whole bunch of other possibilities) prevent this from happening. One solution would be to save the current string at the top of the loop and at the bottom check whether the length has changed. If not, a syntax error must be on the current line.
Good catch, and I like your proposed solution. I'll create a test case and (hopefully) working solution as soon as I can.
I implemented your proposed solution, and included a test (the one you included); you can browse them at https://github.com/dlc/toml/commit/9ea4a942dc9ade98c9d0604cb1e3846284c63345. This is obviously a pretty simple solution and is probably missing quite a bit, so I'm not going to push it to CPAN yet, while I try some more testing.
Subject: Re: [rt.cpan.org #83836] Malformed strings send parser into an endless loop
Date: Sat, 9 Mar 2013 15:37:39 -0600
To: Darren Chamberlain via RT <bug-TOML [...] rt.cpan.org>
From: Matthias Bethke <matthias [...] towiski.de>
Darren Chamberlain via RT on Fri, Mar 08, 2013 at 07:40:01PM -0500: Show quoted text
> This is obviously a pretty simple solution and is probably missing quite a bit, so I'm not going > to push it to CPAN yet, while I try some more testing.
Awesome, thanks for the speedy fix! If you appended the current first input line to the "Syntax error" message (because that's necessarily where the error is), it would help the user debugging their configs though. cheers, Matthias
How's this look: perl -Mblib -MTOML -wle '($t, $e) = from_toml(qq(foo = "bar"\nbaz = "quux)); $t || print $e' Syntax error at line 2: baz = "quux The code is committed to the master branch on githib.
I think this issue was resolved. Can you close this issue?