Hey MS, here's an apparent problem in the base class library. I pulled
the email validation pattern
"^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})"
from http://regexlib.com.
If I validate the email address "te**@someverylongemailaddress.com"
against it by just creating a RegEx and calling IsMatch it works fine,
but if I create a schema defining a simple type restricting an
xs:string by the regex pattern, it takes over full minute at 100% cpu
to match. This is true either when validating from the vs.net ide or
from an executable instantiating a validatingreader. The time to match
seems to be exponential against the length of the text.
I'm no regex expert, so please let me know if this is just a problem
with the expression, and if so what a good email address validating
expression would be. We need full unicode support in the email
addresses.
Here's a doc and some schema to reproduce. Just open both in the ide
and then use the vs.net menu to validate the xml.
<?xml version="1.0" encoding="utf-8" ?>
<email xmlns="http://tempuri.org/XMLSchema1.xsd"
value="te**@someverylongemailaddress.com" />
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="XMLSchema1"
targetNamespace="http://tempuri.org/XMLSchema1.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema1.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="email">
<xs:complexType>
<xs:attribute name="value">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})"
/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>