Page 1 of 2

7.90.0417+ Script Arg following Heredoc upset parser

Posted: 27 Oct 2010 21:58
by TheQwerty
AKA: The Curse of the Sandwiched Heredoc

Code: Select all

"Fine"
	$msg = <<<HEREDOC
Here be dragons!
HEREDOC;
	End 0, "$msg", 1;
	//No stop! Don't try to parse me!
	Echo "Jolly oh!";

"Also Fine"
	End 0, <<<HEREDOC
Here be dragons!
HEREDOC;
	//No stop! Don't try to parse me!
	Echo "Jolly oh s'more!";

"F7U12"
	End 0, <<<HEREDOC
Here be dragons!
HEREDOC
	, 1;
	//No stop! Don't try to parse me!
	Echo "Oh dear!";

"Not you too!"
	End 0, <<<HEREDOC
Here be dragons!
HEREDOC
	, 1;
	/*No stop! Don't try to parse me!*/
	Echo "Oh fudge!";
Legend tells of a type of string that has carried a curse since birth, or at least a very young age, that the villagers have often referred to as Herr-Dok, or Heredoc in some translations.

It is said that Heredoc is very similar to all other types of strings in most ways, but that when surrounded by arguments it will strike out and attack the next comment that it finds. Heredoc infects that comment and convinces it to believe it is not just an empty vessel in this world but an all important part of the community that must be treated like the Functions and Commands it lives with!

The poor comment overtaken by these illusions of grandeur carries along with it the curse until at the most inconvenient time it infects and destroys the entire village! But by now the Heredoc has had plenty of time to escape and hide in wait for its next opportunity to spread evil.

If the legend is to be trusted there is only one man whom wields the power to break this curse... but until that dawn arrives village after village will fall to the Curse of the Sandwiched Heredoc!


TL;DR: Using HEREDOC as an interior argument causes the parser to attempt to execute the next comment it finds. Yielding not so hilarious results.

Re: 7.90.0417+: Scripting: Arg following Heredoc upsets Parser

Posted: 28 Oct 2010 20:22
by admin
:) Curse confirmed and banned.

Re: 7.90.0417+: Scripting: Arg following Heredoc upsets Parser

Posted: 03 Nov 2010 21:30
by TheQwerty
I thought you had cured us but I stumbled on a related curse today....

Code: Select all

"The"
	End 0, <<<HEREDOC
''
HEREDOC;

/* related */

"Curse"
	End 0, <<<HEREDOC
""
HEREDOC;

/* of unclosed quotes */

"has"
	End 0, <<<HEREDOC
'
HEREDOC;

/* not yet */

"been cured"
	End 0, <<<HEREDOC
"
HEREDOC;

/* unfortunately */
And no I was not sitting on this until v9.70, just happened to use a contraction in a dialog today.. Sorry!

Re: 7.90.0417+: Scripting: Arg following Heredoc upsets Parser

Posted: 04 Nov 2010 14:06
by admin
Wow, tricky. Working on it...

Re: 7.90.0417+: Scripting: Arg following Heredoc upsets Parser

Posted: 04 Nov 2010 14:26
by TheQwerty
What's unfortunate about it is the bug was present but not visible in my script file for the last few weeks because I had a script like this:

Code: Select all

"Update"
  Echo <<<HEREDOC
Select 'Copy All Items'.
Don't be alarmed I will fully restore everything!
HEREDOC;
  //Script stuff
  Echo <<<HEREDOC
You didn't copy the items!
HEREDOC;
So I ended up with an even number of quotes which appeased XY and made things look fine, but had I not used the contraction in the second HEREDOC, it would have been visible.

And since that code had been working fine for the last week, it made debugging everything to find the culprit a bit frustrating, though it probably pales in comparison to fixing.

Re: 7.90.0417+: Scripting: Arg following Heredoc upsets Parser

Posted: 05 Nov 2010 10:09
by admin
Should be fixed in next version. Quite a challenging bit of parsing.

Re: 7.90.0417+: Scripting: Arg following Heredoc upsets Parser

Posted: 08 Nov 2010 19:51
by TheQwerty
Looks cured... hopefully that's the end of the Heredoc curses.. :P

Re: [Fixed] 7.90.0417+ Script Arg following Heredoc upset Parser

Posted: 08 Nov 2010 21:23
by TheQwerty
Jumped the gun:

Code: Select all

/* ' */
"It"
	End 1, <<<HEREDOC
'
HEREDOC;
/* lives! */
EDIT: I've attached the script I've been working on that keeps finding these, it is a work in progress so no one use it for anything. And do not add this to any libraries or collections of scripts. I repeat DO NOT USE!

Re: [Fixed] 7.90.0417+ Script Arg following Heredoc upset Parser

Posted: 08 Nov 2010 21:45
by admin
TheQwerty wrote:Jumped the gun:

Code: Select all

/* ' */
"It"
	End 1, <<<HEREDOC
'
HEREDOC;
/* lives! */
EDIT: I've attached the script I've been working on that keeps finding these, it is a work in progress so no one use it for anything. And do not add this to any libraries or collections of scripts. I repeat DO NOT USE!
Wow, but I could fix it again. Will be ready for the next one you find... :twisted:

Re: 7.90.0417+ Script Arg following Heredoc upset parser

Posted: 09 Nov 2010 16:02
by TheQwerty
Well you fixed the sample script but there's still something wrong as evidenced by the script I had attached...
So if you're bored you can try to hunt it down, or wait until I find the time... :P

Re: 7.90.0417+ Script Arg following Heredoc upset parser

Posted: 09 Nov 2010 16:20
by TheQwerty
Bad:

Code: Select all

"A"
	End 1, <<<HEREDOC
HEREDOC
	, 1;
/* Err */
"B"
	End 1, <<<HEREDOC
HEREDOC;
Okay (heredoc is not middle argument):

Code: Select all

"A"
	End 1, <<<HEREDOC
HEREDOC;
/* Err */
"B"
	End 1, <<<HEREDOC
HEREDOC;
Okay (second heredoc is now otherdoc):

Code: Select all

"A"
	End 1, <<<HEREDOC
HEREDOC
	, 1;
/* Err */
"B"
	End 1, <<<OTHERDOC
OTHERDOC;

Re: 7.90.0417+ Script Arg following Heredoc upset parser

Posted: 09 Nov 2010 17:09
by SkyFrontier
:?

Suggestion:
wazzapdoc
:mrgreen:
(sorry, I HAD to do that... lol)

Re: 7.90.0417+ Script Arg following Heredoc upset parser

Posted: 09 Nov 2010 20:49
by admin
TheQwerty wrote:Bad:

Code: Select all

"A"
	End 1, <<<HEREDOC
HEREDOC
	, 1;
/* Err */
"B"
	End 1, <<<HEREDOC
HEREDOC;
Sigh.
Fixed.
Again.

Re: 7.90.0417+ Script Arg following Heredoc upset parser

Posted: 09 Nov 2010 20:54
by TheQwerty
admin wrote:Sigh.
Fixed.
Again.
If your fix gets XY to correctly display the menu for that attached script it will take me longer to find any more problems (assuming there's still some corner case we haven't stumbled over). :P

Re: 7.90.0417+ Script Arg following Heredoc upset parser

Posted: 09 Nov 2010 21:00
by admin
TheQwerty wrote:
admin wrote:Sigh.
Fixed.
Again.
If your fix gets XY to correctly display the menu for that attached script it will take me longer to find any more problems (assuming there's still some corner case we haven't stumbled over). :P
Looks like it does it correctly. :)