41

I've noticed strange things happening to code in comments lately

Wrote the following comment

`"XS1".getBytes(Charset.forName("US-ASCII"‌​))`

After adding the comment, this appeared however:

"XS1".getBytes(Charset.forName("US-ASCII"‌​;))

Just for fun I added a backslash before the ", i.e.

`"XS1".getBytes(Charset.forName("US-ASCII\"‌​))`

but this resulted in

"XS1".getBytes(Charset.forName("US-ASCII\&quo‌​t;‌​))

Also I observed code at the end of the link text breaking the link markup.

I checked the page containing the comment in Firefox and Chrome and both rendered the result the same...

What is happening there?

I noticed it here: Part of a string not getting inserted (not the exact code comment text, but I tested and deleted some versions of this comment, including the ones mentioned above.)

16
  • can you provide a link please?
    – Sklivvz
    Commented Aug 17, 2016 at 16:42
  • 15
    "XS1".getBytes(Charset.forName("US-ASCII"‌​)) Commented Aug 17, 2016 at 16:46
  • 6
    @Sklivvz meta.stackoverflow.com/questions/332658/… Commented Aug 17, 2016 at 16:46
  • @Sklivvz added a link to the question. Not exactly the text in the question, but I've tested these comment texts below that comment, but deleted those comments afterwards, since they weren't adding anything of value...
    – fabian
    Commented Aug 17, 2016 at 16:56
  • 6
    I see you're using Java. "You_should_totally_drop_that_and_use_jQuery"" Commented Aug 17, 2016 at 17:29
  • 2
    ^-- It seems to only be triggered for strings over a certain length containing no whitespace and at least three double quotes. Commented Aug 17, 2016 at 17:31
  • 16
    reproed, i'll take a look soonish, like tomorrow
    – Sklivvz
    Commented Aug 17, 2016 at 17:36
  • 4
    It seems to only happen at specific offsets or something though. \" many times: \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"
    – Siguza
    Commented Aug 17, 2016 at 19:46
  • 7
    @Sklivvz what happened to my 6-8 random units of time!?!
    – Braiam
    Commented Aug 17, 2016 at 19:46
  • 2
    Can someone add a screenshot of the bug for those future visitors from the land where this is fixed? Commented Aug 17, 2016 at 20:02
  • 4
    @Braiam 6-8 sevenths of a day ;) Commented Aug 17, 2016 at 20:40
  • 1
    I've encountered an issue where SO adds invisible characters to comments - for example, in this comment: codegolf.stackexchange.com/questions/89572/… invisible characters are added after g in length or after c in slice. The characters added are also strange - \u200c and \u200b
    – eithed
    Commented Aug 17, 2016 at 23:33
  • 2
    probably related: Link in the comments is rendered with semicolon
    – Bergi
    Commented Aug 17, 2016 at 23:42
  • straaaange things... (If you had a Disney childhood you'd get the pun)
    – Ali Bdeir
    Commented Aug 18, 2016 at 9:27
  • @eithedog I've noticed that when copying code from comments and sometimes answers but never really thought anything of it Commented Aug 18, 2016 at 9:29

1 Answer 1

18

Fixed.

Here's the thing. We insert an invisible, optional non-breaking character after 60 uninterrupted characters, every 20. This is to allow comments to wrap when you do shenanigans like write VERYLONGSEQUENCESOFCHARACTERSWITHOUTANYSPACEJUSTBECAUSEYOUCAN.

The algorithm did not take into account html entities, and in this case it put this character in the middle of ".

Now the algorithm is aware of them. Next step: invoke Cthulhu.

7
  • Or Zalgo, if you're using regexes.
    – Cerbrus
    Commented Aug 18, 2016 at 12:14
  • 10
    Wouldn't it be better to just use word-wrap: break-word;? This would only break words when necessary - in fact, .post-text, .wmd-preview even use it to prevent the exact same issue inside post contents. Inserting spaces just seems absurdly hackish, especially since longer character will still break it, eg. WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW Commented Aug 18, 2016 at 12:24
  • 1
    @NiettheDarkAbsol sure, as soon as we get out of having a table-based layout with variable width, we'll use break-word. If you investigate a tad deeper (including javascript) you'll know what I mean...
    – Sklivvz
    Commented Aug 18, 2016 at 12:40
  • 1
    @Sklivvz The solution to that, from an answer given right here on SO, is to use lable-layout:fixed.
    – Mr Lister
    Commented Aug 18, 2016 at 12:44
  • 1
    @MrLister Although that ends up causing issues with the vote/flag columns no longer being wide enough because they rely on "bad" table behaviour... Seems like a rewrite is needed there! Commented Aug 18, 2016 at 12:59
  • Is this overflow, by-design and as expected? (Oh and grats on getting to 20k, you now have those privileges which you always had ;)..) Commented Aug 18, 2016 at 15:49
  • @BhargavRao it's as expected, we can't fix all the breakages without fixing the HTML first.
    – Sklivvz
    Commented Aug 18, 2016 at 17:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .