I know it's weird...


  • Considered Harmful

    Found in the wild:

    protected string getDocumentAttribute(string sId, object oDocumentContent) { string sPattern = sId + @"""><!\[CDATA\[([^[]+)\]";
    	Regex oR = new Regex(sPattern);
    	Match oM = oR.Match(oDocumentContent.ToString());
    
    	if (oM.Success == true)
    	{
    		// i know doing a trim on the end is weird but for some reason 
    		// the regexp isn't lopping of the end like it should be
    		return oM.Groups[1].ToString().TrimEnd(new char[] {']'});
    	}
    	else
    	{
    		return &quot;&quot;;
    	}
    }
    

    Of course, the regular expression was being "greedy" and capturing up to the second ] in ]]>. If there were any "[" characters in the escaped content, or "]" characters after it, it would mangle it even worse.

    WTFs a-plenty, but The Real WTF is hand-parsing XML in .NET.



  • The RealWTF is the retarded variable/parameter naming

    • oh we need to use Hungarian notation, but 3 letters is too much so we'll just use 1
    • oh everything is an object so let's prefix the rest with "o"
    • and let's just use one letter to name our variable.



      Even regex and match would have been better.



      oM.Success == true != false?


  • @joe.edwards said:

    WTFs a-plenty, but The Real WTF is hand-parsing XML in .NET.

    Of course, but my in-brain RegEx Parser has problems with that one... There appear to be two unclosed [ in there and a misplaced +? Or is that a typo for ([^[]+) (which of course, would have been a typo for ([^]]+))?


    Edit: Fixed corrected CS WTF "typo".



  •  They say that regex may be used as a solution to your problem, and then you have two problems.

    This guy has a couple more.



  • @derula said:

    ([^\[+)
     

    It should be ([^\[]+)



  • @dhromed said:

     They say that regex may be used as a solution to your problem, and then you have two problems.

    This guys has a couple more.

    It's better than "using" XML like this:

    <questnotes>
      <quest123>Some text</quest123>
      <quest8321>Some other text</quest8321>
      <quest7><![CDATA[Some
    multilined
    text]]></quest7>
    </questnotes>
    But at least the DTD to that can be auto-generated.


  • @dhromed said:

    @derula said:

    ([^[+)
     

    It should be ([^[]+)


    Okay, now I see the WTF. Community Server replaces [] with []. WTF.



  •  

    What's up with the fruity tag obsession anyway?


  • @Zecc said:

     

    What's up with the fruity tag obsession anyway?

     

     

    Hell if I knew.



  •  

    Okay, now I see the WTF. Community Server replaces [] with [. WTF.



  • It's the low hanging fruit.



  • @dhromed said:

    It's the low hanging fruit.
    You mean nuts?



  • @Zecc said:

    You mean nuts?
     

    That was the seed of my personal fruit meme, yes.



  • @derula said:

    @dhromed said:

    @derula said:

    ([^[+)
     

    It should be ([^[]+)


    Okay, now I see the WTF. Community Server replaces [] with [. WTF.

    This is not actually a WTF, it's the way to escape [] so that it doesn't begin a BBcode.



  • You are belong to yustom XML like this

     <LBegriff href='a006_auto_fence.xml'>Automatic Fence</LBegriff>

    But for each letter of the alphabet they use a seperate file so you have a.xml, b.xml, ..., z.xml



  • @Spectre said:

    @derula said:
    @dhromed said:
    @derula said:
    ([^[+)
    It should be ([^[]+)

    Okay, now I see the WTF. Community Server replaces [] with [. WTF.

    This is not actually a WTF, it's the way to escape [ so that it doesn't begin a BBcode.

    Wait. Most methods of escaping I've seen prepend a character. There's of course classical \ escape character, or also '''' means ''' in Pascal (probably others too), or // starting a comment... but that way's just retarded. You don't write <> in HTML to get a < either, and it's in no way feeling natural.

    Also to my knowledge, [quote] is the only friggen bbcode in the forum. By the way: writing []quote] will not result in [quote], it will actually start a quote (at least in preview), so there. WTF.


  • Discourse touched me in a no-no place

    @derula said:

    Also to my knowledge, [quote] is the only friggen bbcode in the forum
    [code][]code][]/code][/code]
    (trwtf being I needed &#91; to escape the [] in the quote which didn't work in the reply, where []] did.)



  • What cheese me off the most is that there's approximately 400 drop-in rich text editors out there, most of which are free, and many of which work fine with the iPhone. This one, however, is a gigantic piece of shit. It's low-hanging fruit that would improve this forum immensely without fixing a single line of back-end code, and it's still not being plucked.


  • Discourse touched me in a no-no place

    @blakeyrat said:

    What cheese me off the most is that there's approximately 400 drop-in rich text editors out there, most of which are free, and many of which work fine with the iPhone. This one, however, is a gigantic piece of shit. It's low-hanging fruit that would improve this forum immensely without fixing a single line of back-end code, and it's still not being plucked.

    I gave up on the editor on here long ago. Now I just use the 'Plain Text' one and put in my own HTML.



    That said, I do use a more up to date version of tinymce on my site, and it seems to work a lot better than the version on here.



  • @blakeyrat said:

    What cheese me off the most is that there's approximately 400 drop-in rich text editors out there, most of which are free, and many of which work fine with the iPhone. This one, however, is a gigantic piece of shit. It's low-hanging fruit that would improve this forum immensely without fixing a single line of back-end code, and it's still not being plucked.

    It's TinyMCE which is one of the most commonly used rich text editors on the web.  It's actually not bad, we're just using an ancient version and it seems the CS devs added extensions to it to make it suck.



  • @morbiuswilters said:

    It's actually not bad, we're just using an ancient version and it seems the CS devs added extensions to it to make it suck.
     

    This is a seemingly accurate rendition of reality.



  • @derula said:

    Wait. Most methods of escaping I've seen prepend a character. There's of course classical \ escape character, or also '''' means ''' in Pascal (probably others too), or // starting a comment... but that way's just retarded. You don't write <> in HTML to get a < either, and it's in no way feeling natural.

    Think of it as a BBcode that inserts a left bracket in your post.

    @derula said:

    Also to my knowledge, [quote] is the only friggen bbcode in the forum.

    To [i]my[/i] knowledge, all of [url=http://thedailywtf.com/Info/BBCode.aspx]these[/url] work too.

    @derula said:

    By the way: writing []quote] will not result in [quote], it will actually start a quote (at least in preview),

    Well... Community Server is TRWTF, as always.

    []quote]



  • @Spectre said:

    To my knowledge, all of these work too.

    Last time I checked [code]code[/code] didn't work. I doubt that [b]b[/b], [i]i[/i] or [u]u[/u] work either.

    [code]
    code
    code
    code
    [/code]



  • Code works fine. Didn't you see that it changed the text to fixed width fonts? Probably wraps it in <pre>.



  • @Kyanar said:

    Code works fine. Didn't you see that it changed the text to fixed width fonts? Probably wraps it in <pre>.
    Doesn't work if you don't have the font.



  • @Lingerance said:

    @Kyanar said:
    Code works fine. Didn't you see that it changed the text to fixed width fonts? Probably wraps it in <pre>.
    Doesn't work if you don't have the font.

    <font face="Lucida Console" size="2">

    Wow. Just... wow. What's so hard about <pre><code>?



  • @Lingerance said:

    @Kyanar said:
    Code works fine. Didn't you see that it changed the text to fixed width fonts? Probably wraps it in <pre>.
    Doesn't work if you don't have the font.

    How the hell do you not have that font?  I have it, on fucking Linux, no less.



  • @morbiuswilters said:

    How the hell do you not have that font?  I have it, on fucking Linux, no less.
    You do? All I have is Lucida Sans Typewriter, and that’s only because I installed sun-java6-fonts.



  • @snover said:

    @morbiuswilters said:

    How the hell do you not have that font?  I have it, on fucking Linux, no less.
    You do? All I have is Lucida Sans Typewriter, and that’s only because I installed sun-java6-fonts.

    Well, I guess.  The code blocks show up in monospace for me, which is good enough.

     

    Maybe my Linux e-peen is just bigger than yours.  Don't feel bad, don't cry.  It's going to make everything alright...


  • Garbage Person

    @joe.edwards said:

    WTFs a-plenty, but The Real WTF is hand-parsing XML in .NET.
    To be fair I'm yet to meet a resource that explains how to parse XML using the library without being all "OH THATS EASY HERES SOME CODE JUST CARGO CULT IT"

     

    (Cue a link to some MSDN document thats only findable after 3PM every other thursday during a month with a blue moon)



  • @snover said:

    @morbiuswilters said:

    How the hell do you not have that font?  I have it, on fucking Linux, no less.
    You do? All I have is Lucida Sans Typewriter, and that’s only because I installed sun-java6-fonts.

    Still, how the hell do you not have that - or any other - font?  Linux has fonts like other people have cockroaches!  One of the first things I ever did when I first got my hands on a linux machine was run "ls -R /", in order to get a mile-high view of what was where on the whole filing system... in the time I sat there watching it, I saw literally a dozen or more entire duplicate sets of installed fonts scroll past, every application seemed to have its own fonts.  Well, that was a few years ago, maybe linux has got better by now, but from the sound of your system it's gone too far in the other direction! 

     



  • @DaveK said:

    Linux has fonts like other people have cockroaches!
     

    Ubuntu by default has very few fonts.

    I find it hard to find fonts for Linux. Especially the good ones like the new Vista ones.



  • @Weng said:

    @joe.edwards said:

    WTFs a-plenty, but The Real WTF is hand-parsing XML in .NET.
    To be fair I'm yet to meet a resource that explains how to parse XML using the library without being all "OH THATS EASY HERES SOME CODE JUST CARGO CULT IT"

     

    (Cue a link to some MSDN document thats only findable after 3PM every other thursday during a month with a blue moon)

     

    Well, since the XML-navigation is virtually identical to HTML DOM-navigation, they're probably assuming you know the latter in the docs. (To be honest, I've never read the docs either-- I saw a couple examples, said, "oh it's just like DOM" and took it from there. Plus Intellisense.)


Log in to reply