Jibble

Author Topic: Problems with symbols disappearing in posts  (Read 314 times)

Snarky

  • Global Moderator
  • Global Moderator
  • Mittens Lord
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Problems with symbols disappearing in posts
« on: 24 Mar 2020, 14:00 »
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, 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 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?).
« Last Edit: 24 Mar 2020, 14:05 by Snarky »

Re: Problems with symbols disappearing in posts
« Reply #1 on: 01 Apr 2020, 13:35 »
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
  1.   x[x.length] = textFields[i] + '=' + document.forms.postmodify[textFields[i]].value.replace(/&#/g, '&#');
  2.  
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

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.
« Last Edit: 01 Apr 2020, 13:39 by Khris »
Fail at Floaty Rog' now!  still having to deal with what games are going through

AGA

  • Adventure Game Aficionado
  • Administrator
  • Mittens Deity
  • ¡Qué alí­vio!
    • Lifetime Achievement Award Winner
    • AGA worked on one or more games that won an AGS Award!
    •  
    • AGA worked on one or more games that was nominated for an AGS Award!
Re: Problems with symbols disappearing in posts
« Reply #2 on: 02 Apr 2020, 11:08 »
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
  1. 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...

Re: Problems with symbols disappearing in posts
« Reply #3 on: 03 Apr 2020, 12:24 »
Yes, it works here now, too, thanks!
Fail at Floaty Rog' now!  still having to deal with what games are going through

TheManInBoots

  • Epically wrote function to declare an int
Re: Problems with symbols disappearing in posts
« Reply #4 on: 04 Apr 2020, 01:13 »
I'm really happy about this improvement! This has been bugging me for a while.
Thanks
« Last Edit: 04 Apr 2020, 01:21 by TheManInBoots »

TheManInBoots

  • Epically wrote function to declare an int
Re: Problems with symbols disappearing in posts
« Reply #5 on: 12 Apr 2020, 13:55 »
This does not seem to have been properly debugged.

It happened to me again with ++ symbols.
« Last Edit: 15 May 2020, 19:52 by TheManInBoots »