7.90.0417+ Script Arg following Heredoc upset parser

Things you’d like to miss in the future...
Forum rules
:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:

:info: Please include the following information:
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".

:warnred20: :warnred20: :warnred20: :warnred20: :warnred20: READ THIS AND DO IT!!! :warnred20: :warnred20: :warnred20: :warnred20: :warnred20:
TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

7.90.0417+ Script Arg following Heredoc upset parser

Post 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.
Last edited by TheQwerty on 08 Nov 2010 21:28, edited 2 times in total.

admin
Site Admin
Posts: 65332
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

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

Post by admin »

:) Curse confirmed and banned.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

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

Post 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!

admin
Site Admin
Posts: 65332
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

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

Post by admin »

Wow, tricky. Working on it...

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

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

Post 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.

admin
Site Admin
Posts: 65332
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

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

Post by admin »

Should be fixed in next version. Quite a challenging bit of parsing.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

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

Post by TheQwerty »

Looks cured... hopefully that's the end of the Heredoc curses.. :P

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

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

Post 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!
Attachments
ToolbarMenu.xys
(6.47 KiB) Downloaded 124 times

admin
Site Admin
Posts: 65332
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

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

Post 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:

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: 7.90.0417+ Script Arg following Heredoc upset parser

Post 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

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: 7.90.0417+ Script Arg following Heredoc upset parser

Post 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;

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: 7.90.0417+ Script Arg following Heredoc upset parser

Post by SkyFrontier »

:?

Suggestion:
wazzapdoc
:mrgreen:
(sorry, I HAD to do that... lol)
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

admin
Site Admin
Posts: 65332
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: 7.90.0417+ Script Arg following Heredoc upset parser

Post by admin »

TheQwerty wrote:Bad:

Code: Select all

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

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: 7.90.0417+ Script Arg following Heredoc upset parser

Post 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

admin
Site Admin
Posts: 65332
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: 7.90.0417+ Script Arg following Heredoc upset parser

Post 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. :)

Post Reply