Skip to content

Commit

Permalink
Fix escaped quote parsing inside double-quoted string
Browse files Browse the repository at this point in the history
  • Loading branch information
UnkindPartition committed Oct 18, 2010
1 parent 330d0f6 commit 1bf4b1d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Parse.hs
Expand Up @@ -52,7 +52,7 @@ doubleQuoted = do
return $ Bare w return $ Bare w
where where
ordinary_symbol = noneOf "$`\\\"" <|> ordinary_symbol = noneOf "$`\\\"" <|>
do char '\\'; lookAhead (noneOf escapables); return '\\' try (do char '\\'; lookAhead (noneOf escapables); return '\\')


backquoted = do backquoted = do
RS { insideBackQuotes = alreadyInsideBackQuotes RS { insideBackQuotes = alreadyInsideBackQuotes
Expand Down Expand Up @@ -116,7 +116,7 @@ readHereDoc (delim,i,isQuoted) = rememberHereDoc i . joinWordParts =<< hereDocLi
return $ Bare w return $ Bare w
where where
ordinary_symbol = noneOf "$`\\\n" <|> ordinary_symbol = noneOf "$`\\\n" <|>
do char '\\'; lookAhead (noneOf escapables); return '\\' try (do char '\\'; lookAhead (noneOf escapables); return '\\')


-- If several contiguous strings in a word are of the same type, -- If several contiguous strings in a word are of the same type,
-- join them -- join them
Expand Down Expand Up @@ -335,7 +335,7 @@ redirection = try $ do
return $ Bare w return $ Bare w
where where
ordinary_symbol = noneOf "\\\"" <|> ordinary_symbol = noneOf "\\\"" <|>
do char '\\'; lookAhead (noneOf escapables); return '\\' try (do char '\\'; lookAhead (noneOf escapables); return '\\')




assignment = try $ do assignment = try $ do
Expand Down
3 changes: 3 additions & 0 deletions testingtool.hs
Expand Up @@ -33,6 +33,9 @@ tests = [T command "functions"
,T simpleCommand "line-cont-after-space" ,T simpleCommand "line-cont-after-space"
,T token_word "line-cont-in-dquotes" ,T token_word "line-cont-in-dquotes"
,T token_word "line-cont-in-squotes" ,T token_word "line-cont-in-squotes"

,T doubleQuoted "escape-dquote"
,T doubleQuoted "escape-dquote-2"
] ]




Expand Down
1 change: 1 addition & 0 deletions tests/escape-dquote-2.sh
@@ -0,0 +1 @@
"a\"b"
1 change: 1 addition & 0 deletions tests/escape-dquote-2.sh.golden
@@ -0,0 +1 @@
DQuoted [Bare "a",Escaped '"',Bare "b"]
1 change: 1 addition & 0 deletions tests/escape-dquote.sh
@@ -0,0 +1 @@
"\""
1 change: 1 addition & 0 deletions tests/escape-dquote.sh.golden
@@ -0,0 +1 @@
DQuoted [Escaped '"']

0 comments on commit 1bf4b1d

Please sign in to comment.