KJS regexp patch

Dmitriy Taychenachev dimichxp at gmail.com
Thu May 6 13:40:07 BST 2010


Hi,

I have found two KJS bugs in regexp optimisation logic 
(regexp.cpp:sanitizePattern, introduced in r1088985):
1. The nonCapturing variable may become stale, since it is not refreshed in 
every loop iteration (for example in regexp "A(?:.|\s)*A(.|\s)*" the second 
group will be considered non-capturing, which is wrong.
2. The function may corrupt the regexp is the first group will be ignored as 
minimal, "tmp.append(np, previdx, idx-previdx+5);" will copy 5 characters 
forward to idx, while next statement "previdx = idx+6;" will drop six. 
Example: A((?:.|\s)*?)A((?:.|\s)+) will be rewriten to A((?:.|\s)?)A([\w\W]+) 
.

The fixes are trivial. In the second case I have dropped else clause at all, 
since the pending characters would be copied by next rewrite (if any will 
happen), or by finishing code (if any already happened).

Thanks, Dmitriy.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kjs_regexp.patch
Type: text/x-patch
Size: 892 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20100506/88584ab8/attachment.bin>


More information about the kfm-devel mailing list