(Forgivingly) permit ["/.] in attribute names.

This commit is contained in:
vi 2014-07-25 13:47:57 +08:00
parent 9880f64013
commit 9f9480c049
2 changed files with 9 additions and 14 deletions

View File

@ -84,23 +84,11 @@ possibly c = (char c *> return ())
ident :: Parser T.Text
ident =
takeWhile1 (\c -> isAlphaNum c
|| c == '-'
|| c == '_'
|| c == ':'
|| c == '.'
)
takeWhile1 (\c -> isAlphaNum c || c `elem` "-_:.")
attribute_ident :: Parser T.Text
attribute_ident =
takeWhile1 (\c -> isAlphaNum c
|| c == '-'
|| c == '_'
|| c == ':'
|| c == '('
|| c == ')'
|| c == ','
)
takeWhile1 (\c -> isAlphaNum c || c `elem` "-_:(),\"/.")
tagopen :: Bool -> Parser Tag
tagopen cventities = do

View File

@ -45,6 +45,13 @@ spec = do
"<br / >" ~> tagopen False
`shouldParse` TagOpen "br" [] True
it "successfully (and forgivingly) parses <title foo\">" $
"<title foo\">" ~> tagopen False
`shouldParse` TagOpen "title" [Attribute "foo\"" ""] False
it "successfully (and forgivingly) parses <title https://github.com/alpmestan/taggy\">" $
"<title https://github.com/alpmestan/taggy/\">" ~> tagopen False
`shouldParse` TagOpen "title" [Attribute "https://github.com/alpmestan/taggy/\"" ""] False
it "can successfully convert entities in attribute values: <a title=\"&nbsp;Hello!\">" $
"<a title=\"&nbsp;Hello!\">" ~> tagopen True
`shouldParse` TagOpen "a" [Attribute "title" "\160Hello!"] False