kjs regular expressions problem.

Luciano Montanaro mikelima at cirulla.net
Tue Jun 8 13:45:34 BST 2004


El Tuesday 08 June 2004 14:13, Harri Porten escribió:
> Hi,
> 
> On Tue, 8 Jun 2004, Luciano Montanaro wrote:
> 
> > The problem I found is in the regular expression code, when the PCRE code
> > is not used.
> > In this case, if the regular expression cannot be compiled, the match()
> > function crashes.
> 
> Can you provide a concrete test case? I haven't managed to produce a crash
> with this regexp and PCRE disabled.

Go to http://mail.virgilio.it
and fill in the form (the first text-entry must be filled with an 
email-address-like text, the second should contain a password... make it "pippo").

The script doing the check is at:

http://mail.virgilio.it/mail/home/scripts/cpiulogic2.js,
the problematic match is at line 200.


The problem is that the javascript that verifies the password wants to match
something like "/[^a-zA-Z0-9._-àèìòù]/". The dot in the character class is interpreted
by regcomp as a "collation class" introducer, as I gather from googling around (the
error is REG_ECOLLATE) which is unrecognized, and leaves the regexp uninitialized.
When this happens, the match() method segfaults. The "." in the regular expression
should probably be escaped, but in any case, we should not segfault...

> 
> The ascii() function shouldn't be a problem in this case - it just needs a
> more appropriate name like latin1() ;)

Yes, but what if the original expression is not latin-1 but utf-8?
I'm not sure regcomp can handle such a locale, but...

In any case, the expression, when printed to stderr looks strange. 
That could be due to my locale being in UTF-8, while the string is a valid 
latin-1 string, however.

 


> 
> Harri.
> 
> 
> 




More information about the kfm-devel mailing list