4

So, I had to stand up for my beloved bananas, and show how some piece of code failed to deal with them.

Said code would transform a banana into a lead surrogate inside a span tag, followed by a trail surrogate inside another span tag. For example purposes I wanted to paste the bad result in a comment. It looks like this in my browser:

"<span>�</span><span>�</span>"

That was when I discovered that using lone surrogates in comments doesn't work. That's fine-ish. Lone surrogates are invalid after all. But I lost my comment text without an opportunity to fix it!

I tried it again, and again, until I realised it was failing because of the surrogates. And then I realised that posting such comments would send me to the same page with the comment text in a URL query parameter, like https://stackoverflow.com/questions/15501534/search-and-replace-unicode-character?comment=%22%3Cspan%3E%ED%A0%BC%3C%2Fspan%3E%3Cspan%3E%ED%BD%8C%3C%2Fspan%3E%22.

This is rather minor, but it would have been nicer if I had a popup saying "your comment is bad and you should feel bad" or something, instead of nuking my comment into the URL.


And I discovered that posting questions with lone surrogates doesn't quite work either :)

6
  • You are posting an invalidly encoded comment, the server is probably failing to decode it, and it wisely discards it. What do you expect a web server to do with those? Commented Mar 19, 2013 at 15:05
  • 3
    @MartijnPieters Well, he said what he expected. He expected an error message so that he knows his text was invalid and can't be posted, along with the ability to edit the text, rather than needing to re-write it from scratch.
    – Servy
    Commented Mar 19, 2013 at 15:37
  • @Servy: I suspect this is a lower-level system rejecting the comment (web server, framework) instead. Commented Mar 19, 2013 at 15:40
  • 2
    Even if it is a bug, is it really worth fixing? I'd say "if you break it, you get to keep both parts." After all, you can't easily mess this up manually, and even if you do, no permanent damage is done. Commented Mar 19, 2013 at 15:41
  • 2
    @JoachimSauer: The fact that it's going to the URL means that the comment text is not going where it should be. This smells sort of like SQL injection (entered text going deeper into the code than intended). Commented Mar 19, 2013 at 16:00
  • Speaks for itself. <span>�</span><span>�</span>
    – Slate StaffMod
    Commented Jun 25 at 17:56

0

You must log in to answer this question.

Browse other questions tagged .