Prevent segfaults on unterminated strings

A single quote input was causing segfaults due to sneaking past the
string termination logic. This patch corrects that lapse in conditional
by only parsing strings where a closing quote was found. All other
strings are rejected as invalid.

Big thanks to Jean-Charles Campagne (@jccampagne) for reporting the
issue.