Skip to content
Browse files

Fix escaped quote parsing inside double-quoted string

  • Loading branch information...
1 parent 330d0f6 commit 1bf4b1d0e191e0b3a9b20133d85482b66dafd071 @feuerbach feuerbach committed Oct 19, 2010
Showing with 10 additions and 3 deletions.
  1. +3 −3 Parse.hs
  2. +3 −0 testingtool.hs
  3. +1 −0 tests/escape-dquote-2.sh
  4. +1 −0 tests/escape-dquote-2.sh.golden
  5. +1 −0 tests/escape-dquote.sh
  6. +1 −0 tests/escape-dquote.sh.golden
View
6 Parse.hs
@@ -52,7 +52,7 @@ doubleQuoted = do
return $ Bare w
where
ordinary_symbol = noneOf "$`\\\"" <|>
- do char '\\'; lookAhead (noneOf escapables); return '\\'
+ try (do char '\\'; lookAhead (noneOf escapables); return '\\')
backquoted = do
RS { insideBackQuotes = alreadyInsideBackQuotes
@@ -116,7 +116,7 @@ readHereDoc (delim,i,isQuoted) = rememberHereDoc i . joinWordParts =<< hereDocLi
return $ Bare w
where
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,
-- join them
@@ -335,7 +335,7 @@ redirection = try $ do
return $ Bare w
where
ordinary_symbol = noneOf "\\\"" <|>
- do char '\\'; lookAhead (noneOf escapables); return '\\'
+ try (do char '\\'; lookAhead (noneOf escapables); return '\\')
assignment = try $ do
View
3 testingtool.hs
@@ -33,6 +33,9 @@ tests = [T command "functions"
,T simpleCommand "line-cont-after-space"
,T token_word "line-cont-in-dquotes"
,T token_word "line-cont-in-squotes"
+
+ ,T doubleQuoted "escape-dquote"
+ ,T doubleQuoted "escape-dquote-2"
]
View
1 tests/escape-dquote-2.sh
@@ -0,0 +1 @@
+"a\"b"
View
1 tests/escape-dquote-2.sh.golden
@@ -0,0 +1 @@
+DQuoted [Bare "a",Escaped '"',Bare "b"]
View
1 tests/escape-dquote.sh
@@ -0,0 +1 @@
+"\""
View
1 tests/escape-dquote.sh.golden
@@ -0,0 +1 @@
+DQuoted [Escaped '"']

0 comments on commit 1bf4b1d

Please sign in to comment.
Something went wrong with that request. Please try again.