[geany/geany] 0b010e: Bash: Fix handling of quoted HereDoc delimiters

Colomban Wendling git-noreply at xxxxx
Tue Jul 23 15:25:53 UTC 2013


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Tue, 23 Jul 2013 15:25:53 UTC
Commit:      0b010e2f45b2e874fc91ebbbabf176fc887290a9
             https://github.com/geany/geany/commit/0b010e2f45b2e874fc91ebbbabf176fc887290a9

Log Message:
-----------
Bash: Fix handling of quoted HereDoc delimiters

Imported from upstream Scintilla bb784e214430498e91c9935bbc841c798629212f

Closes [bugs:#952]


Modified Paths:
--------------
    scintilla/lexers/LexBash.cxx

Modified: scintilla/lexers/LexBash.cxx
14 files changed, 12 insertions(+), 2 deletions(-)
===================================================================
@@ -437,12 +437,22 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
 						HereDoc.State = 1;
 					}
 				} else if (HereDoc.State == 1) { // collect the delimiter
-					if (setHereDoc2.Contains(sc.ch) || sc.chPrev == '\\') {
+					// * if single quoted, there's no escape
+					// * if double quoted, there are \\ and \" escapes
+					if ((HereDoc.Quote == '\'' && sc.ch != HereDoc.Quote) ||
+					    (HereDoc.Quoted && sc.ch != HereDoc.Quote && sc.ch != '\\') ||
+					    (HereDoc.Quote != '\'' && sc.chPrev == '\\') ||
+					    (setHereDoc2.Contains(sc.ch))) {
 						HereDoc.Append(sc.ch);
 					} else if (HereDoc.Quoted && sc.ch == HereDoc.Quote) {	// closing quote => end of delimiter
 						sc.ForwardSetState(SCE_SH_DEFAULT);
 					} else if (sc.ch == '\\') {
-						// skip escape prefix
+						if (HereDoc.Quoted && sc.chNext != HereDoc.Quote && sc.chNext != '\\') {
+							// in quoted prefixes only \ and the quote eat the escape
+							HereDoc.Append(sc.ch);
+						} else {
+							// skip escape prefix
+						}
 					} else if (!HereDoc.Quoted) {
 						sc.SetState(SCE_SH_DEFAULT);
 					}



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list