A malformed anchor tag breaks the preview page. April 11, 2005 12:30 PM   Subscribe

Posting with a malformed anchor tag makes a mess of the preview page, and comment text is gone when you hit Back to fix it. [more details inside]
posted by odinsdream to Bugs at 12:30 PM (7 comments total)

If you post a comment that ends with a link, but you miss one of the quotation marks, like so:

<a href="http://www.google.com>google.com</a>

...you make a mess of the resulting comment preview box, at least in Firefox. Earlier this morning, some combination of missing quotation marks caused the entire remainder of the page (internet explorer) to become a link, including the entire comment text box. That made it impossible to click in the text box and fix the error. When I hit Back to fix it on the previous page, the comment box was blank.

I recovered the text by viewing the source code on the Preview page and copying that. I'm having trouble re-creating the error right now on Firefox. Can anyone else try it in other browsers? It happened on AskMe, if that matters.
posted by odinsdream at 12:40 PM on April 11, 2005

my AIM sent me a link and when i clicked it went to a sight with boners and loud shouting "hey i'm looking at gay porn!" this was write after i was on mefi matt can you fix this?
posted by quonsar at 12:53 PM on April 11, 2005

I just tested your example on AskMe/MeTa/MeFi in IE 6. I did not encounter the problems you are describing.

The comments section was not broken, and the closing " mark was inserted for me. When I hit back, the comments section was filled in with my original (wrong) html. YMMV

Were you trying to post a comment or a question? My tests were only conducted in the comments field. Since I'm currently stuck on my work box, I'm unable to try it in firefox.
posted by raedyn at 12:59 PM on April 11, 2005

I've had this error before with Firefox. And it's annoying as hell, as clicking anywhere in the comment box (to, say, fix the malformed input) makes Firefox attempt to load the malformed url.

But this is clearly a Firefox problem; it shouldn't allow malformed input to turn an input box into an anchor tag.

That said, mathowie's code parses the input text into an HTML tree, converts special characters, like "<" into HTML entities like "<", and adds any missing closing tags. This is good, safe coding, it protects the site from malformed HTML input, and I commend it.

But it also makes correcting malformed input more tedious, as the user needs to remove the entities and re-type the tags the user initially typed, and remove the trailing closing tags. And doing the server-side processing of the text into an HTML tree slows down the turn-around time, the time it takes from pressing the "Preview" button to getting back the page.

So my request to mathowie would be, keep doing your safe processing when the user hits the "Post" button, but don't process the text when the user hits the "Preview" button. This will make MetafIlter faster on previews without compromising the web site.
posted by orthogonality at 1:01 PM on April 11, 2005

... and when i clicked it went to a sight with boners and loud shouting "hey i'm looking at gay porn!" ...

Thank you. That's very helpful.
posted by odinsdream at 1:15 PM on April 11, 2005

i wish someone would parse my input text into an HTML tree.
posted by quonsar at 1:33 PM on April 11, 2005

quonsar writes "i wish someone would parse my input text into an HTML tree."

Actually, I know a firefox extension that does just that....
posted by orthogonality at 2:47 PM on April 11, 2005

« Older Link suddenly disappeared   |   Why didn't my ad run? Newer »

You are not logged in, either login or create an account to post comments