'&' escapes to &

Hello Guys

I have a PHP Page that uses GET, to get parameters from a URL.
So to make that work i have to use the PHP Syntax ‘&’ if I want to use multiple queries.
Example:
www.WEBPAGE/index.php?variableX=1&variableY=2&variableZ=3 and so on.

The Problem is, if I add this link into the assets, it automatically fills it out with &
This “destroys” my PHP script, and it doesn’t get the variable correctly anymore.

Also, everytime I make a change on the Webpage asset, it adds another amp;

Example:
www.WEBPAGE/index.php?variableX=1&variableY=2&&variableZ=3

Is there a way to stop this behaviour in Screenly?
Or else, can I change the PHP to “accept” ‘&amp’; as ‘&’?

Thanks for the Help

Edit:
Clearer Problem description

I have read that this was fixed in a commit, however this still does not work.

SOLVED

Instead of using multiple _GET in my PHP to send parameters, I now use 1 _GET and made an array out of it.
By using the array there is no need to use the char ‘&’.
My Code:
values = explode(",", _GET[“id”]);

Then I can just do:
https://my_site/my_php.php?id=VAR1,VAR2,VAR3,VAR4

An with this Screenly no longer adds amp; to my URL!!!

Yeah that’s one workaround. This has however been fixed in the the developer branch so I would encourage you to switch to that one as it has a lot of important fixes/updates.

That specific Raspi is a 2B and I couldn’t get it to upgrade without “dying” :slight_smile:
Also thank you for all the good work you put into Screenly!!

Hmm yeah, that’s an old device. We might need to drop support for anything older than Pi 3 in the near future, as older devices simply do not have enough RAM to cope with modern web browsers/content. The older releases will of course still be available however.

@RomanCrossIT
You could have also just copied over the few lines from the server.py file from developer/master branch onto the production branch you have installed, this would have fixed that issue.

The changes you would have edited are as follows…
Under this function: def prepare_asset_v1_2
You would change the current code and make the edits below:

    ampfix = "&"
    name = escape(get('name').replace(ampfix, '&'))
    if unique_name:
        with db.conn(settings['database']) as conn:

I have copied over the if unique_name: just so that you get a reference point of where the edits should be made by comparing what you currently have vs what I am showing here.

The same goes for the other lines, which are just a few lines down from those I posted above…

    uri = (get('uri')).replace(ampfix, '&').replace('<', '&lt;').replace('>', '&gt;').replace('\'', '&apos;').replace('\"', '&quot;')

    if uri.startswith('/'):
        if not path.isfile(uri):

The important line here being the entire uri = one…

If you make these changes and save that file and reload the screenly-* services, your assets would properly allow for & symbols and it would also fix a naming bug that would duplicate the &amp when it was part of an assets’ name and this asset was activated, deactivated, and activated again.

Sorry for the late answer.

I bought a Raspi 3B and installed the experimental branch, so everything works fine now :slight_smile:

Greetings Roman

1 Like