After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 612984 - str:replace goes into infinite loop when second argument is empty string
str:replace goes into infinite loop when second argument is empty string
Status: RESOLVED FIXED
Product: libxslt
Classification: Platform
Component: general
1.1.26
Other Mac OS
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2010-03-15 21:42 UTC by Peter Pawlowski
Modified: 2012-09-04 09:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Rewrite of str:replace (11.99 KB, patch)
2010-07-06 23:22 UTC, Nick Wellnhofer
none Details | Review

Description Peter Pawlowski 2010-03-15 21:42:44 UTC
This is very easy to demonstrate and is pretty bad. If you accidentally specify an empty string as the second argument to str:replace, xsltproc (or whatever you are using for the transformation) will just hang.

Try my test XSL below:

$ ./xsltproc --version
Using libxml 20707, libxslt 10126 and libexslt 815
xsltproc was compiled against libxml 20707, libxslt 10126 and libexslt 815
libxslt 10126 was compiled against libxml 20707
libexslt 815 was compiled against libxml 20707

$ cat ~/testloop.xsl
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:str="http://exslt.org/strings"
>
<xsl:template match="/*">
  <xsl:variable name="loop-replace" select="str:replace('foo', '', 'baz')" />
</xsl:template>
</xsl:stylesheet>

$ ./xsltproc ~/testloop.xsl ~/testloop.xsl
^C
Comment 1 Nick Wellnhofer 2010-07-06 23:22:28 UTC
Created attachment 165390 [details] [review]
Rewrite of str:replace

This patch should fix this bug.
Comment 2 Daniel Veillard 2012-09-04 09:01:17 UTC
I think that was fixed when fixing

https://bugzilla.gnome.org/show_bug.cgi?id=569703

Daniel