HTML comments and programmers' stupidity



  •  I'm literraly shocked at how many wtf's you can find here: Firefox bug 214476

     It's a bug reported in 2003 that say's Firefox handles HTML comments incorrectly if "--" is found in the comments.

    The problem is most browsers ignore that but Firefox follows the standard and renders comments incorrectly if you  follow the standard.

     Now here's the funny part:

    • HTML 5 treats "--" differently and the comment rules are different so we'll soon see html5 pages sent with bad TLD and rendered badly in Firefox
    • IDN domains have "--" in the url so it will be funny to see pages screwed by reverse proxies adding comments at the end of pages containing the IDN domains
    • IE developers were so smart they thought it would be great to have conditional comments so now you can have Javascript code inside comments which obviously can contain code like "i--;" which obviously screws Firefox
    The way comments are specified in the HTML 4 standard is so screwed up you have to see for yourself to believe it: HTML comments

     HTML5 comments rules are also funny: HTML 5 comments

    <dfn id="syntax-comments" title="syntax-comments">Comments</dfn> must start with the four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS (<!--). Following this sequence, the comment may have text, with the additional restriction that the text must not start with a single U+003E GREATER-THAN SIGN ('>') character, nor start with a U+002D HYPHEN-MINUS (-) character followed by a U+003E GREATER-THAN SIGN ('>') character, nor contain two consecutive U+002D HYPHEN-MINUS (-) characters, nor end with a U+002D HYPHEN-MINUS (-) character. Finally, the comment must be ended by the three character sequence U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN (-->)

     

    ps. Oh my god, this forum software and editor sucks so much... it doesn't let you enter links from the toolbar but you can just edit the html code directly... stupid...



  • The HTML 4 standard was wrong. It was a complete nightmare that nobody understood correctly. Not only that, but the relevant standard - SGML (which HTML 4 is based on) - is not even an open standard; you have to pay for it. So HTML authors cannot be expected to know its quirks, because none of them will have ever read it.

    SGML comments are so convoluted that nobody understood them, such that I had to write an extensive article about them to explain to the poor HTML authors what on earth is going on. The HTML5 authors realised it was a mistake to follow SGML when it comes to comments - HTML 5 is no longer based on SGML, since SGML has far too much ridicolous stuff that nobody understands, and no browsers ever understood. This is why the HTML 5 authors went for what seems convoluted from a parsing approach, but is far more intuitive to authors, and does pretty much what all other browsers always did. The parsing section of the HTML 5 spec goes into far more detail about what to do with double dashes inside comments, which boils down to "do what all the non-mozilla browsers used to do", which is what authors expect.

    It means that Firefox is wrong to treat comments in HTML as if it were SGML. The old standard was wrong. It happens sometimes. There is a good blog post made by the author of HTML 5, when he realised that it was the old standard that was wrong, and not the browsers that ignored the SGML comments - specifically "Sometimes, the spec is wrong, and we just have to fix it.".



  • @mariushm said:

    ps. Oh my god, this forum software and editor sucks so much... it doesn't let you enter links from the toolbar but you can just edit the html code directly... stupid...

    Err...you can add hyperlinks from the toolbar, only that it's a bit tricky to get the proper icons to activate.

    Here's what works for me: select a portion of text, then then "chain" icon lights up and you can select it, adding a link and even an alt description (title). It's a bit verbose but it works. Or else use the HTML editing, if there are a lot of links to paste.




  • Consider yourself lucky, I don't even get a toolbar in my browser.



  • @gherkin said:

    Consider yourself lucky, I don't even get a toolbar in my browser.

    This is probably because your browser has crappy RTF support.  Get a better browser. 



  •  @gherkin said:

    Consider yourself lucky, I don't even get a toolbar in my browser.

     And how do you get the HTML editing option, then? :-S



  • @C4I_Officer said:

    And how do you get the HTML editing option, then? :-S

    I can just type HTML into the plain textarea.

    Browser rich text editors all work by using some fancy JavaScript to replace a plain textarea widget with a rich text editor, but in the end what gets posted back is just plain HTML.

    Of course I'm not surprised that the JavaScript on Community Server isn't cross-browser compatible. Dozens of other implementations work fine here.



  • @gherkin said:

    @C4I_Officer said:
    And how do you get the HTML editing option, then? :-S

    I can just type HTML into the plain textarea.

    Browser rich text editors all work by using some fancy JavaScript to replace a plain textarea widget with a rich text editor, but in the end what gets posted back is just plain HTML.

    Of course I'm not surprised that the JavaScript on Community Server isn't cross-browser compatible. Dozens of other implementations work fine here.

    It's TinyMCE and plenty of browsers have crappy RTF implementations which makes them nearly unusable.  It seems TinyMCE is just defaulting to a plain text area rather than trying to work with your browser's most likely flawed rich text engine.  It would probably be more WTF yfor it to actually try to use rich text as certain features would not work right and the resulting HTML would be a mess. 



  • @morbiuswilters said:

    and the resulting HTML would be a mess.
    The resulting HTML is always a mess.  Who would even notice?



  • @bstorer said:

    @morbiuswilters said:

    and the resulting HTML would be a mess.
    The resulting HTML is always a mess.  Who would even notice?

    I didn't mean the HTML would be badly-formed, but that it won't even render close to the same as the rich text it was based on. 



  • @morbiuswilters said:

    It's TinyMCE and plenty of browsers have crappy RTF implementations which makes them nearly unusable.  It seems TinyMCE is just defaulting to a plain text area rather than trying to work with your browser's most likely flawed rich text engine. 
     

    Does TinyMCE actually us the browser's internal RTF editors (do they have one? I've never seen a javascript API or something like that which should make it possible to use it)? Besides, woudn't a wrapper like TinyMCE be perfect to solve this kinds of bugs/incompatibilities? Besides:

    @http://tinymce.moxiecode.com/ said:


    • Browserfriendly - Mozilla, MSIE, FireFox, Opera, Safari and Chrome.


  • @gherkin said:

    ...JavaScript...

    ...cross-browser compatible...

     

     

    Didn't really expect to see these two things in the same sentence :-p



  • @dtech said:

    Does TinyMCE actually us the browser's internal RTF editors (do they have one? I've never seen a javascript API or something like that which should make it possible to use it)?

    Yes.  IE was the first to have rich text, Mozilla created the Midas spec which MS later adopted.  Safari and Opera later adopted variations of it, but there are more compatiblity problems with those implementations.

     

    @dtech said:

    Besides, woudn't a wrapper like TinyMCE be perfect to solve this kinds of bugs/incompatibilities?

    TinyMCE just enables the feature and calls into the API.  It cannot actually change the way the rich text feature is implemented.  TinyMCE claims compatiblity with Opera and Safari, but last I checked it was limited functionality.  Not sure if it still does, but TinyMCE used to throw up an alert box in those browsers telling the user a lot of features would not work.  Due to this, some people who use TinyMCE simply opt to disable support for those browsers altogether rather than deal with the "quirks" of Opera and Safari.



  • @morbiaswilters said:

    It's TinyMCE and plenty of browsers have crappy RTF implementations which makes them nearly unusable. It seems TinyMCE is just defaulting to a plain text area rather than trying to work with your browser's most likely flawed rich text engine. It would probably be more WTF yfor it to actually try to use rich text as certain features would not work right and the resulting HTML would be a mess.

    I use TinyMCE on my own website and it works fine on Safari - I don't think the one on CS uses any features mine doesn't. My guess is CS just has an old version of TinyMCE.

    Edit: just checked, and CS's TinyMCE uses a subset of the features I have enabled on mine.



  • @gherkin said:

    @morbiaswilters said:
    It's TinyMCE and plenty of browsers have crappy RTF implementations which makes them nearly unusable. It seems TinyMCE is just defaulting to a plain text area rather than trying to work with your browser's most likely flawed rich text engine. It would probably be more WTF yfor it to actually try to use rich text as certain features would not work right and the resulting HTML would be a mess.

    I use TinyMCE on my own website and it works fine on Safari - I don't think the one on CS uses any features mine doesn't. My guess is CS just has an old version of TinyMCE.

    Edit: just checked, and CS's TinyMCE uses a subset of the features I have enabled on mine.

    That may be true, but I'm fairly certain this is a relatively old version of CS as well.  Plus, it's the free version, so it might be stripped-down intentionally.  CS has plenty of massive WTFs, but the editor is hardly one of them.


Log in to reply