kjs regular expressions problem.

Harri Porten porten at froglogic.com
Tue Jun 8 15:18:38 BST 2004


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.

> > 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.

> 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.





More information about the kfm-devel mailing list