AGS Development > Site & Forum Reports

Problems with symbols disappearing in posts

(1/2) > >>

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?).

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 ---  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

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.

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 ---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...

Yes, it works here now, too, thanks!

I'm really happy about this improvement! This has been bugging me for a while.


[0] Message Index

[#] Next page

Go to full version