Problem with an ampersand in XUL

Users and developers helping users with generic and technical Pale Moon issues on all operating systems.
Please direct questions that are Mac or Linux-specific (dealing with installation and OS integration) to the appropriate Linux or Mac board.

Moderator: trava90

Forum rules
This board is for technical/general usage questions and troubleshooting for the Pale Moon browser only. The main focus here is on Pale Moon on Windows. Please direct your questions that are specific for Linux and Mac to the dedicated boards for those operating systems.
Technical issues and questions not related to the Pale Moon browser should be posted in other boards!
Please keep off-topic and general discussion out of this board, thank you!
User avatar
back0rifize
Moonbather
Moonbather
Posts: 51
Joined: 2016-05-08, 02:26

Problem with an ampersand in XUL

Post by back0rifize » 2019-02-28, 21:32

Hello!

Today I've faced the problem: I created a file, called "about.xul". In this file, I placed a link to my forum's profile. And now, when I try to call this XUL, PM tells me, that I have a syntax error issue.
I'm sure, that an ampersand is the cause of problem, because if I replace it with any other symbol, It seems to be alright.
Attachments
_problem.png

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 8884
Joined: 2012-10-09, 19:37
Location: Seriphia Galaxy

Re: Problem with an ampersand in XUL

Post by New Tobin Paradigm » 2019-02-28, 21:50

In XML the ampersand is a special char.. To use an ampersand literal in an element or attr you can use the entity form:

Code: Select all

&
Though if it is not inside an attr but just enclosed in an element you can also use CDATA but this is easier. XML is always strict in processing the markup so unlike most forms of HTML there isn't any kind of quirks mode in the rendering engine or whatnot.
How far are you prepared to go? How much are you prepared to risk? How many people are you prepared to sacrifice for victory?
Are you willing to die friendless, alone, deserted by everyone? Because that's what may be required of you in the war that is to come.

Image

User avatar
back0rifize
Moonbather
Moonbather
Posts: 51
Joined: 2016-05-08, 02:26

Re: Problem with an ampersand in XUL

Post by back0rifize » 2019-03-01, 02:36

Strange, I thought that the "quotes" must disable any special chars and wrap them into the simple literal symbols :think: ...
And so we have another problem: if "&" change to "&", this link will be broken. I mean, this forum does not parse this link.
Of course, I can code a little script and then all will be alright, but I want to know, why this suppose to be?

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 8884
Joined: 2012-10-09, 19:37
Location: Seriphia Galaxy

Re: Problem with an ampersand in XUL

Post by New Tobin Paradigm » 2019-03-01, 09:31

Try using this instead..

Code: Select all

%26
How far are you prepared to go? How much are you prepared to risk? How many people are you prepared to sacrifice for victory?
Are you willing to die friendless, alone, deserted by everyone? Because that's what may be required of you in the war that is to come.

Image

User avatar
back0rifize
Moonbather
Moonbather
Posts: 51
Joined: 2016-05-08, 02:26

Re: Problem with an ampersand in XUL

Post by back0rifize » 2019-03-01, 10:05

Believe me, I've already tried this too with no result ;) . Thank you.

User avatar
JustOff
Moon Magic practitioner
Moon Magic practitioner
Posts: 2083
Joined: 2015-09-03, 19:47
Location: UA
Contact:

Re: Problem with an ampersand in XUL

Post by JustOff » 2019-03-01, 10:56

back0rifize wrote:And so we have another problem: if "&" change to "&", this link will be broken.
No, it will not.
Here are the add-ons I made in a spare time. That was fun!

If you have any questions or problems regarding the migration of my extensions to GitHub, feel free to contact me through a PM.

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 8884
Joined: 2012-10-09, 19:37
Location: Seriphia Galaxy

Re: Problem with an ampersand in XUL

Post by New Tobin Paradigm » 2019-03-01, 12:50

JustOff it depends on the browser and server software. I have ran into this my self.. However, the %26 SHOULD work...

Well maybe you should just assign the attr using js instead.
How far are you prepared to go? How much are you prepared to risk? How many people are you prepared to sacrifice for victory?
Are you willing to die friendless, alone, deserted by everyone? Because that's what may be required of you in the war that is to come.

Image

User avatar
JustOff
Moon Magic practitioner
Moon Magic practitioner
Posts: 2083
Joined: 2015-09-03, 19:47
Location: UA
Contact:

Re: Problem with an ampersand in XUL

Post by JustOff » 2019-03-01, 13:27

Maybe in some cases something might go wrong, but I checked that in the about.xul file in the Calendate extension in question, & works as expected.
Here are the add-ons I made in a spare time. That was fun!

If you have any questions or problems regarding the migration of my extensions to GitHub, feel free to contact me through a PM.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 29251
Joined: 2011-08-28, 17:27
Location: Tranås, SE
Contact:

Re: Problem with an ampersand in XUL

Post by Moonchild » 2019-03-01, 13:43

This forum blocks URLs with "&" as a literal string in the URL to mitigate bot abuse - most websites do not.
"Son, in life you do not fight battles because you expect to win, you fight them merely because they need to be fought." -- Snagglepuss
Image

User avatar
JustOff
Moon Magic practitioner
Moon Magic practitioner
Posts: 2083
Joined: 2015-09-03, 19:47
Location: UA
Contact:

Re: Problem with an ampersand in XUL

Post by JustOff » 2019-03-01, 14:09

There will be no "&" in the forum URL, because when it's used in the "href" attribute of the "label" element in the "about.xul", it becomes "&" when the link is opened.
Here are the add-ons I made in a spare time. That was fun!

If you have any questions or problems regarding the migration of my extensions to GitHub, feel free to contact me through a PM.

User avatar
back0rifize
Moonbather
Moonbather
Posts: 51
Joined: 2016-05-08, 02:26

Re: Problem with an ampersand in XUL

Post by back0rifize » 2019-03-02, 00:36

Moonchild wrote:This forum blocks URLs with "&" as a literal string in the URL to mitigate bot abuse - most websites do not.
Other words, I was right that neither "&" nor "%26" will not work? In my case this is right what exactly happened.
JustOff wrote:There will be no "&" in the forum URL, because when it's used in the "href" attribute of the "label" element in the "about.xul", it becomes "&" when the link is opened.
With all my respect, but it's not working. Maybe I'm dumb?

One way or the other, I've done an update yesterday, and simply remove this profile link completely. I didn't include a JS-file in "About XUL", because the only reason, why I have no desire in doing it - is include yet another JS only for solving such kind of a situation. It's better to abandon an idea, than to use a complex way to solve a simple problem.
Think, this topic may be closed. Thanks to all for your answers!

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 8884
Joined: 2012-10-09, 19:37
Location: Seriphia Galaxy

Re: Problem with an ampersand in XUL

Post by New Tobin Paradigm » 2019-03-02, 01:29

You can add javascript directly to XUL and if you CDATA the contents of the script tag you can add that one onload function to add the attr. It just isn't best practice to do js in xul files in-line but know what.. I don't have a problem for a one off workaround..
How far are you prepared to go? How much are you prepared to risk? How many people are you prepared to sacrifice for victory?
Are you willing to die friendless, alone, deserted by everyone? Because that's what may be required of you in the war that is to come.

Image

User avatar
back0rifize
Moonbather
Moonbather
Posts: 51
Joined: 2016-05-08, 02:26

Re: Problem with an ampersand in XUL

Post by back0rifize » 2019-03-02, 03:18

Yeah, I know about CDATA, and I've already used it in previous versions (below 3.0, Firefox only). Since I've ported my add-on to PM, I use a links to a JS-files with a window.addEventListener(); instead for more clearance.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 29251
Joined: 2011-08-28, 17:27
Location: Tranås, SE
Contact:

Re: Problem with an ampersand in XUL

Post by Moonchild » 2019-03-02, 08:07

back0rifize wrote:Other words, I was right that neither "&" nor "%26" will not work? In my case this is right what exactly happened.
No, you're not right. I'm only saying that if your code does a request to the forum server with "&" as a literal string in the URL, it will be refused. I didn't say anything about %26, nor did I say anything about how it's specifically handled in your situation or what is sent to the server -- just providing information that might save you some troubleshooting IF you're sending "&" in your URLs for some reason!
"Son, in life you do not fight battles because you expect to win, you fight them merely because they need to be fought." -- Snagglepuss
Image

User avatar
JustOff
Moon Magic practitioner
Moon Magic practitioner
Posts: 2083
Joined: 2015-09-03, 19:47
Location: UA
Contact:

Re: Problem with an ampersand in XUL

Post by JustOff » 2019-03-02, 08:25

back0rifize wrote:With all my respect, but it's not working.
Please check your PM.
Here are the add-ons I made in a spare time. That was fun!

If you have any questions or problems regarding the migration of my extensions to GitHub, feel free to contact me through a PM.

User avatar
back0rifize
Moonbather
Moonbather
Posts: 51
Joined: 2016-05-08, 02:26

Re: Problem with an ampersand in XUL

Post by back0rifize » 2019-03-02, 11:40

JustOff wrote:Please check your PM.
Problem solved, thank you, JustOff!

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 8884
Joined: 2012-10-09, 19:37
Location: Seriphia Galaxy

Re: Problem with an ampersand in XUL

Post by New Tobin Paradigm » 2019-03-02, 15:40

Mind sharing this solution?
How far are you prepared to go? How much are you prepared to risk? How many people are you prepared to sacrifice for victory?
Are you willing to die friendless, alone, deserted by everyone? Because that's what may be required of you in the war that is to come.

Image

User avatar
JustOff
Moon Magic practitioner
Moon Magic practitioner
Posts: 2083
Joined: 2015-09-03, 19:47
Location: UA
Contact:

Re: Problem with an ampersand in XUL

Post by JustOff » 2019-03-02, 16:47

Tobin, your initial advice to use "&" was absolutely correct, I just applied it to the back0rifize's extension and sent him the result. I guess he simply made a typo somewhere when previously reported a failure.
Here are the add-ons I made in a spare time. That was fun!

If you have any questions or problems regarding the migration of my extensions to GitHub, feel free to contact me through a PM.

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 8884
Joined: 2012-10-09, 19:37
Location: Seriphia Galaxy

Re: Problem with an ampersand in XUL

Post by New Tobin Paradigm » 2019-03-02, 17:05

No, that isn't smoke, it's steam. Steam from the steamed clams we're having. Mmmm, steamed clams!
How far are you prepared to go? How much are you prepared to risk? How many people are you prepared to sacrifice for victory?
Are you willing to die friendless, alone, deserted by everyone? Because that's what may be required of you in the war that is to come.

Image

User avatar
JustOff
Moon Magic practitioner
Moon Magic practitioner
Posts: 2083
Joined: 2015-09-03, 19:47
Location: UA
Contact:

Re: Problem with an ampersand in XUL

Post by JustOff » 2019-03-02, 17:37

Yep. The Aurora Borealis. At this time of year. At this time of day. In this part of the country. Localized entirely within your kitchen.
Here are the add-ons I made in a spare time. That was fun!

If you have any questions or problems regarding the migration of my extensions to GitHub, feel free to contact me through a PM.

Locked