SC replacelist gives a weird result

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

: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: Use Your Profile Or Signature
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: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

SC replacelist gives a weird result

Post by Marco »

I have a small function that replaces html entities in a webpage source code.
Bottom line is, something like "Ratchet & Clanck" should become "Ratchet & Clanck". However,

Code: Select all

replacelist("Ratchet & Clanck", "" & &apos; < >", '" & '' < >', " ");
gives

Code: Select all

Ratchet " & ' < > Clanck
Is there a bug or I'm doing something wrong?
XY 16.20.0100 on 8.1
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

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

Re: SC replacelist gives a weird result

Post by TheQwerty »

Seems to be a bug related to the placement of the double-quotes within the replacelist.

This works:

Code: Select all

replacelist("Ratchet & Clanck", "& &apos; < > "", '& '' < > "', " ");

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: SC replacelist gives a weird result

Post by bdeshi »

Code: Select all

replacelist("Ratchet & Clank", "&apos; & " < >", ''' & " < >', " ");
replacelist("Ratchet & Clank", "& &apos; " < >", '& '' " < >', " ");
works.
And, this works too.

Code: Select all

replacelist("Ratchet & Clank", "" & &apos; < >", '"" & '' < >', " ");
checked in 15.80.0003 (at random).
Definitely a bug.

The bug appears if a single-quoted string begins with any kind of quote.
However, output seems proper anyways. ::text '"hello"'; confirm('"hello"'); //"hello"
Crazy.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: SC replacelist gives a weird result

Post by PeterH »

replacelist("Ratchet & Clanck", "" & &apos; < >", '" & '' < >', " ");

:arrow: am I wrong :?:

I'd say e.g. in "Ratchet & Clanck" &amp is a variable.
If &amp is meant as a string, use singele quotes: 'Ratchet & Clanck' etc.
(As being used for the 3rd operand :P )

edit
OK: what I said doesn't relate to the basic problem - this is as you described it!

But, to be on the right side of life, I'd never ever write a string like $amp etc inside double quotes, as long as it is not meant as a variable.
As long as it is not initialized as a variable, it's used as written. (I.e.: you are lucky.) But if you happened to use any of these &-names as a variable before, it will be interpreted as that variable. And then: happy debugging :whistle:

Marco
Posts: 2354
Joined: 27 Jun 2011 15:20

Re: SC replacelist gives a weird result

Post by Marco »

PeterH, I think you're confusing $ with & :)

TheQwerty & SammaySarkar, thank you both for your tests!
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: SC replacelist gives a weird result

Post by PeterH »

Marco wrote:PeterH, I think you're confusing $ with & :)

TheQwerty & SammaySarkar, thank you both for your tests!
:lol: :oops: :lol:

You are right!
Many(!) years ago I had to work with interpretative language from IBM ('clists') - and those used & as variablename prefixes. In the moment I saw the statements above I automatically felt like home :whistle:

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

Re: SC replacelist gives a weird result

Post by admin »

Fix comes. :whistle:

Post Reply