BaseParsersSpec failure

20 views
Skip to first unread message

Matt Farmer

unread,
Nov 21, 2015, 12:49:53 PM11/21/15
to Lift
Okay… sooo….

While working on making things Travis-publishable I stumbled across a reproducible error where our Markdown parser probably isn’t working like we expect.

[info] BaseParsersTest:
[info] The BaseParsers
[info] - should parse a newline
[info] - should parse whitespace *** FAILED ***
[info]   Expected exception java.lang.IllegalArgumentException to be thrown, but no exception was thrown. (BaseParsersTest.scala:50)
[info] - should be able to look behind
[info] - should parse chars in ranges

The problematic code is this:

    /** accepts one or more spaces or tabs
     * returns the matched whitespace
     */
    def ws:Parser[String] = """( |\t|\v)+""”.r

For some reason, even though this regex won’t match against a \n character, the parser combinator implementation treats this as a parsing success

scala> val parsers = new BaseParsers {}
parsers: net.liftweb.markdown.BaseParsers = $anon$1@627a5dd4

scala> parsers.apply(parsers.ws, "\n")
res2: String =
"
"

scala> parsers.parseAll(parsers.ws, "\n")
res3: parsers.ParseResult[String] =
[2.1] parsed:


According to the spec this should not be the behavior. Anyone have a clue about what is going on here?

Cheers,


Matt Farmer | Blog | Twitter
GPG: CD57 2E26 F60C 0A61 E6D8  FC72 4493 8917 D667 4D07

Antonio Salazar Cardozo

unread,
Nov 24, 2015, 11:37:58 AM11/24/15
to Lift
This looks like it's a change in behavior in Java 8 for \v. It used to mean “vertical tab”,
now it matches any vertical whitespace. Not sure how our previous tests weren't catching
it—we either weren't running them on Java 8, or we weren't running the markdown tests :/

#1733 fixes this.
Thanks,
Antonio
Reply all
Reply to author
Forward
0 new messages