From ad00bfebeefbf296c456893e35ab4cfef5cb3eb6 Mon Sep 17 00:00:00 2001 From: BerndN Date: Tue, 1 Oct 2019 16:46:03 +0200 Subject: [PATCH 1/3] =?UTF-8?q?[Bug=C2=A022396]=20fix=20literal=20"/*"=20i?= =?UTF-8?q?n=20Auto=20Complete=20If=20Structures=20causing=20endless=20loo?= =?UTF-8?q?p?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix consists of emptying all quoted Strings --- .../revsecommoneditorbehavior.livecodescript | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Toolset/palettes/script editor/behaviors/revsecommoneditorbehavior.livecodescript b/Toolset/palettes/script editor/behaviors/revsecommoneditorbehavior.livecodescript index b24dd08a36..82b6f1c431 100644 --- a/Toolset/palettes/script editor/behaviors/revsecommoneditorbehavior.livecodescript +++ b/Toolset/palettes/script editor/behaviors/revsecommoneditorbehavior.livecodescript @@ -2051,6 +2051,26 @@ function autoCompleteIFsAreBalanced pLineNumber, pScript end repeat put line 1 to tCounter of pScript into pScript + + local tWorkText, tOldDelim + + -- remove quoted literals + put the itemDelimiter into tOldDelim + set the itemDelimiter to quote + repeat for each line aLine in pScript + if aLine contains quote then + repeat with i = 1 to the number of items of aLine + if i mod 2 = 0 then + put empty into item i of aLine + end if + end repeat + end if + put aLine & cr after tWorkText + end repeat + delete char -1 of tWorkText + set the itemDelimiter to tOldDelim + put tWorkText into pScript + -- remove slash asterisk comments local tBeginAsterix, tEndAsterix, tCharBegin, tCharEnd @@ -2061,6 +2081,7 @@ function autoCompleteIFsAreBalanced pLineNumber, pScript put offset(tBeginAsterix, pScript) into tCharBegin if tCharBegin is 0 then exit repeat put offset(tEndAsterix, pScript) into tCharEnd + if tCharEnd = 0 then exit repeat delete char tCharBegin to tCharEnd of pScript end repeat From 93de907400445d8bde5cd5456a816e7b76bffaac Mon Sep 17 00:00:00 2001 From: BerndN Date: Tue, 1 Oct 2019 16:51:24 +0200 Subject: [PATCH 2/3] Create bugfix-22396.md --- notes/bugfix-22396.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 notes/bugfix-22396.md diff --git a/notes/bugfix-22396.md b/notes/bugfix-22396.md new file mode 100644 index 0000000000..8646854b94 --- /dev/null +++ b/notes/bugfix-22396.md @@ -0,0 +1 @@ +# Prevent hang of SE if literal "/*" is in script From e8644923e1df6ce8cd2d3045cef36b1bab4e404d Mon Sep 17 00:00:00 2001 From: BerndN Date: Fri, 13 Mar 2020 20:29:55 +0100 Subject: [PATCH 3/3] add another safeguard --- .../behaviors/revsecommoneditorbehavior.livecodescript | 1 + 1 file changed, 1 insertion(+) diff --git a/Toolset/palettes/script editor/behaviors/revsecommoneditorbehavior.livecodescript b/Toolset/palettes/script editor/behaviors/revsecommoneditorbehavior.livecodescript index 82b6f1c431..3e24fa9ed4 100644 --- a/Toolset/palettes/script editor/behaviors/revsecommoneditorbehavior.livecodescript +++ b/Toolset/palettes/script editor/behaviors/revsecommoneditorbehavior.livecodescript @@ -2082,6 +2082,7 @@ function autoCompleteIFsAreBalanced pLineNumber, pScript if tCharBegin is 0 then exit repeat put offset(tEndAsterix, pScript) into tCharEnd if tCharEnd = 0 then exit repeat + if tCharBegin > tCharEnd then exit repeat delete char tCharBegin to tCharEnd of pScript end repeat