Adventure Game Studio | Forums

AGS Development => Site & Forum Reports => Topic started by: Snarky on Tue 24/03/2020 14:00:08

Title: Problems with symbols disappearing in posts
Post by: Snarky on Tue 24/03/2020 14:00:08
Recently there's been a problem where certain symbols do not appear in posts, but are replaced by spaces. See line 16 in the post here (https://www.adventuregamestudio.co.uk/forums/index.php?topic=57826.msg636616763#msg636616763), for example.

Edit: I'm not sure how it's triggered, exactly, since it seems to work OK in this post.

Plus symbols: +
Ampersand symbols: &

(But not in preview, where both symbols fail to render, as well as everything after the ampersand.)

If you quote or edit the post, they remain gone.

Obviously this is very bad when posting code in particular.

In this post (https://www.adventuregamestudio.co.uk/forums/index.php?topic=57875.msg636617710#msg636617710) it's also suggested that under certain circumstances it can "break" the post, though I'm not sure exactly what's meant by that (maybe the preview problem?).
Title: Re: Problems with symbols disappearing in posts
Post by: Khris on Wed 01/04/2020 13:35:17
The bug should be an easy fix; the problem is that the post content is sent as query string, where the ampersand is used as a separator and the plus sign as space.

This line
Code (javascript) Select

  x[x.length] = textFields[i] + '=' + document.forms.postmodify[textFields[i]].value.replace(/&#/g, '&#');

is I guess supposed to deal with ampersands in the post content but doesn't work at all.

The proper function to deal with characters like that is encodeURIComponent (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent)

You can in fact replace ampersands with  %26  and you will see them in the preview, which means the server-side expects URI encoded strings.
Title: Re: Problems with symbols disappearing in posts
Post by: AGA on Thu 02/04/2020 11:08:33
SMF is written to maximise compatibility; it has workaround for super obsolete stuff like IE 4 in it.  Chances are encodeURIComponent wasn't 100% supported at some point so they tried to write their own workaround.

Seems to work okay with that line changed to:

Code (javascript) Select
x[x.length] = textFields[i] + \'=\' + encodeURIComponent(document.forms.postmodify[textFields[i]].value);

I edited the post Snarky linked, and previewed, and it looked okay in both preview and post...
Title: Re: Problems with symbols disappearing in posts
Post by: Khris on Fri 03/04/2020 12:24:58
Yes, it works here now, too, thanks!
Title: Re: Problems with symbols disappearing in posts
Post by: TheManInBoots on Sat 04/04/2020 01:13:24
I'm really happy about this improvement! This has been bugging me for a while.
Thanks
Title: Re: Problems with symbols disappearing in posts
Post by: TheManInBoots on Sun 12/04/2020 13:55:44
This does not seem to have been properly debugged.

It happened to me again with ++ symbols.