[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    Re: KJS regexp patch
From:       Harri Porten <porten () froglogic ! com>
Date:       2010-05-06 13:00:50
Message-ID: Pine.LNX.4.64.1005061457570.26358 () greco ! froglogic ! com
[Download RAW message or body]

Hello Dmitriy,

On Thu, 6 May 2010, Dmitriy Taychenachev wrote:

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

Great! What would be even greater: could you write up some small tests for the 
issues you found? They can be added to the RegExp.js file found in the 
khtmltests module:

  http://websvn.kde.org/trunk/tests/khtmltests/regression/tests/js/

You can easily execute the tests by opening testotherbrowser.html in 
Konqueror.

Harri.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic