What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 133 Stack Exchange communities.

http://stackoverflow.com/questions/434414/what-is-the-most-evil-code-you-have-ever-seen-in-a-production-enterprise-environm/434562#434562

This answer has a code snipet (of purposefully bad code) that creates a double scroll (I guess it's a "div in a div" thing).

Shows fine in IE8 (!), but the double scroll thing is present in Firefox 3.6.13.alt text


Update for reference, the original text/code was:

  • Some genius figured out that you can hook multiple form controls up to the same event handler. How did the programmer handle this?

    private void OperationButton_Click(object sender, EventArgs e)
    {
        Button btn = (Button)sender;
        if (blnModeIsAddMc)
        {
            AddMcOperationKeyPress(btn);
        }
        else
        {
            string strToBeAppendedLater = string.Empty;
            if (btn.Name != "btnBS")
            {
                UpdateText();
            }
            if (txtEdit.Text.Trim() != "Error")
            {
                SaveFormState();
            }
            switch (btn.Name)
            {
                case "btnC":
                    ResetValues();
                    break;
                case "btnCE":
                    txtEdit.Text = "0";
                    break;
                case "btnBS":
                    if (!blnStartedNew)
                    {
                        string EditText = txtEdit.Text.Substring(0, txtEdit.Text.Length - 1);
                        DisplayValue((EditText == string.Empty) ? "0" : EditText);
                    }
                    break;
                case "btnPercent":
                    blnAfterOp = true;
                    if (GetValueDecimal(txtEdit.Text, out decCurrValue))
                    {
                        AddToTape(GetValueString(decCurrValue), (string)btn.Text, true, false);
                        decCurrValue = decResultValue * decCurrValue / intFormatFactor;
                        DisplayValue(GetValueString(decCurrValue));
                        AddToTape(GetValueString(decCurrValue), string.Empty, true, false);
                        strToBeAppendedLater = GetValueString(decResultValue).PadLeft(20)
                                                    + strOpPressed.PadRight(3);
                        if (arrLstTapeHist.Count == 0)
                        {
                            arrLstTapeHist.Add(strToBeAppendedLater);
                        }
                        blnEqualOccurred = false;
                        blnStartedNew = true;
                    }
                    break;
                case "btnAdd":
                case "btnSubtract":
                case "btnMultiply":
                case "btnDivide":
                    blnAfterOp = true;
                    if (txtEdit.Text.Trim() == "Error")
                    {
                        btnC.PerformClick();
                        return;
                    }
                    if (blnNumPressed || blnEqualOccurred)
                    {
                        if (GetValueDecimal(txtEdit.Text, out decCurrValue))
                        {
                            if (Operation())
                            {
                                AddToTape(GetValueString(decCurrValue), (string)btn.Text, true, true);
                                DisplayValue(GetValueString(decResultValue));
                            }
                            else
                            {
                                AddToTape(GetValueString(decCurrValue), (string)btn.Text, true, true);
                                DisplayValue("Error");
                            }
                            strOpPressed = btn.Text;
                            blnEqualOccurred = false;
                            blnNumPressed = false;
                        }
                    }
                    else
                    {
                        strOpPressed = btn.Text;
                        AddToTape(GetValueString(0), (string)btn.Text, false, false);
                    }
    
    
    
                if (txtEdit.Text.Trim() == "Error")
                {
                    AddToTape("Error", string.Empty, true, true);
                    btnC.PerformClick();
                    txtEdit.Text = "Error";
                }
                break;
            case "btnEqual":
                blnAfterOp = false;
                if (strOpPressed != string.Empty || strPrevOp != string.Empty)
                {
                    if (GetValueDecimal(txtEdit.Text, out decCurrValue))
                    {
                        if (OperationEqual())
                        {
                            DisplayValue(GetValueString(decResultValue));
                        }
                        else
                        {
                            DisplayValue("Error");
                        }
                        if (!blnEqualOccurred)
                        {
                            strPrevOp = strOpPressed;
                            decHistValue = decCurrValue;
                            blnNumPressed = false;
                            blnEqualOccurred = true;
                        }
                        strOpPressed = string.Empty;
                    }
                }
                break;
            case "btnSign":
                GetValueDecimal(txtEdit.Text, out decCurrValue);
                DisplayValue(GetValueString(-1 * decCurrValue));
                break;
        }
    }
    
    }
share|improve this question
    
Same in Chrome 6 (Linux) –  Michael Mrozek Jan 3 '11 at 18:39
    
And Chrome 7 (WinXP) –  Daniel DiPaolo Jan 3 '11 at 18:41
    
I'm pretty sure this is related to this problem, though in this case the snippet is supposed to be part of the list, I think. It's possible to "fix" it for this post by removing the empty line in the code, but this is a highly annoying Markdown parser bug, +1. –  Tim Stone Jan 3 '11 at 18:45
    
I can't understand why IE8 got it right. It must be that they had it double-wrong, thus making it appear right... –  MPelletier Jan 3 '11 at 19:37

2 Answers 2

up vote 2 down vote accepted

I'm getting the hang of fixing Markdown issues :)

This will be fixed in the next build.

share|improve this answer
    
Thanks. I never really thought of the extra layer of complexity involved in Markdown (on top of the usual cross-browser HTML fun). So, your work is greatly appreciated! –  MPelletier Jan 7 '11 at 15:07

It's caused by the blank line before the if statement in the screenshot. I removed it.

I've indeed seen this before. Markdown can't properly handle blank lines in code blocks inside a list. Apart from breaking the structure as you found out, it also inserts double blank line for every blank line.

Example:

  • Some List

    Some code. The next line is actually separated by a single blank line.
    
    
    See? It displays as two blank lines!
    
share|improve this answer
    
This was a different issue, but is fixed as well –  balpha Jan 7 '11 at 12:07

You must log in to answer this question.

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