1

Closed

Exception thrown when filtering on strings with curly braces.

description

Thanks for creating and sharing such a great component!

I found that the ADGV had problems filtering strings which had curly braces in them. Since cell string values are later used within the format string passed to StringBuilder.AppendFormat an exception would occur.

I modified the FormatString method in ADGVFilterMenu.cs to escape curly braces in format strings by doubling up on them:
        private String FormatString(String Text)
        {
            String result = "";
            String s;
            String[] replace = { "%", "[", "]", "*", "\"", "`", "\\" };

            for (Int32 i = 0; i < Text.Length; i++)
            {
                s = Text[i].ToString();
                if (replace.Contains(s))
                    result += "[" + s + "]";
                else if (s == "{")
                    result += "{{";
                else if (result == "}")
                    result += "}}";
                else
                    result += s;
            }

            return result.Replace("'", "''");
        }
Closed May 14, 2015 at 2:04 AM by Zubyme
fixed in v0.1.1.0

comments

arstorey wrote Mar 3, 2015 at 9:07 PM

Oops... the changed function should be:

```c# private String FormatString(String Text) { String result = ""; String s; String[] replace = { "%", "[", "]", "*", "\"", "`", "\" };
        for (Int32 i = 0; i             {                s = Text[i].ToString();                if (replace.Contains(s))                    result += "[" + s + "]";                else if (s == "{")                    result += "{{";                else if (s == "}")                    result += "}}";                else                    result += s;            }

        return result.Replace("'", "''");        }```

Zubyme wrote Mar 18, 2015 at 8:35 AM

Hi arstorey!Can you test following code instead?

private String FormatString(String Text) { return Text.Replace("'", "''").Replace("{", "{{").Replace("}", "}}"); }I think that we realy dont need all this replace = { "%", "[", "]", "*", "\"", "`", "\" } symbolsAlso dont forget to change FormatString(String Text) method in SetFilterForm class

Thank you that you have found this bug!

Zubyme wrote May 14, 2015 at 2:01 AM

fixed in [release:611620]

Zubyme wrote May 14, 2015 at 2:03 AM

fixed in v0.1.1.0