Page 1 of 1

SC replacelist gives a weird result

Posted: 25 Jan 2016 18:36
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

Re: SC replacelist gives a weird result

Posted: 25 Jan 2016 18:52
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; < > "", '& '' < > "', " ");

Re: SC replacelist gives a weird result

Posted: 25 Jan 2016 19:02
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.

Re: SC replacelist gives a weird result

Posted: 26 Jan 2016 00:03
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:

Re: SC replacelist gives a weird result

Posted: 26 Jan 2016 01:14
by Marco
PeterH, I think you're confusing $ with & :)

TheQwerty & SammaySarkar, thank you both for your tests!

Re: SC replacelist gives a weird result

Posted: 26 Jan 2016 10:44
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:

Re: SC replacelist gives a weird result

Posted: 02 Feb 2016 21:18
by admin
Fix comes. :whistle: