kjs regular expressions problem.

Luciano Montanaro mikelima at cirulla.net
Tue Jun 8 16:05:47 BST 2004


El Tuesday 08 June 2004 16:18, Harri Porten escribió:
> On Tue, 8 Jun 2004, Luciano Montanaro wrote:
> 
> > 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...
> 
> Definitely not. I neither get an REG_ECOLLATE error nor a crash (if I use
> another invalid regexp) but I blame this on a different version we are
> using. I've added the error checking code (and the "") fallback to the 3.2
> branch. In HEAD I'll look into behaving the same as other other browser,
> i.e. throwing a JS exception.
> 

Things are quite odd indeed. I tried compiling the testkjs program and feeding it 
with the problematic match, but it seems to accept the expression without problems 
when standalone. 

Evidently broken expressions already generate a javascript exception,
since they are trapped by scanRegExp() in the lexer, and I can't easily think of 
something that would dot compile, while passing the validity tests.

> > > 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...
> 
> No. That's a limiation.
> 

Ok. I suppose this is not yet a problem.

> > 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.
> 
> Yes.
> 
> Thanks for the report,
> 
> Harri.
> 
> 

Thank you for your quick reply!

Luciano




More information about the kfm-devel mailing list