From 402e635f8619be9a577366fef117332eddb8fbd9 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sat, 16 Jun 2018 12:30:19 -0700 Subject: [PATCH] Warn about & followed by letters, e.g. http://foo/?a=b&c=d --- src/ShellCheck/Parser.hs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ShellCheck/Parser.hs b/src/ShellCheck/Parser.hs index 2d8168f..83752f6 100644 --- a/src/ShellCheck/Parser.hs +++ b/src/ShellCheck/Parser.hs @@ -1848,16 +1848,23 @@ prop_readSeparator1 = isWarning readScript "a &; b" prop_readSeparator2 = isOk readScript "a & b" prop_readSeparator3 = isWarning readScript "a & b" prop_readSeparator4 = isWarning readScript "a > file; b" +prop_readSeparator5 = isWarning readScript "curl https://example.com/?foo=moo&bar=cow" readSeparatorOp = do notFollowedBy2 (void g_AND_IF <|> void readCaseSeparator) notFollowedBy2 (string "&>") f <- try (do pos <- getPosition char '&' - optional $ do - s <- lookAhead . choice . map (try . string) $ - ["amp;", "gt;", "lt;"] - parseProblemAt pos ErrorC 1109 "This is an unquoted HTML entity. Replace with corresponding character." + optional $ choice [ + do + s <- lookAhead . choice . map (try . string) $ + ["amp;", "gt;", "lt;"] + parseProblemAt pos ErrorC 1109 "This is an unquoted HTML entity. Replace with corresponding character.", + + do + try . lookAhead $ variableStart + parseProblemAt pos WarningC 1132 "This & terminates the command. Escape it or add space after & to silence." + ] spacing pos <- getPosition