KJS regexp patch
Dmitriy Taychenachev
dimichxp at gmail.com
Thu May 6 15:30:28 BST 2010
Hello Harri,
je 22:00:50 ĵaudon la 6-an de Majo vi skribis jenon:
> 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.
Thanks for the advice, I have never heard of khtmltests before, that's great
stuff. I have made tests (patch is attached), but I have really no experience
in tests so can't judge their real worthness (they pass with my patch and fail
without it, though :) ).
Dmitriy.
More information about the kfm-devel
mailing list