parse: improve detection of bad input string