Bug #2735
closedArrayIndexOutOfBoundsException while evaluating regular expression
100%
Description
After upgrading from Saxon 9.4 to 9.6, a regular expression that worked
fine suddenly throws a java.lang.ArrayIndexOutOfBoundsException.
The expression attempts to normalize space between numbers and selected
SI units. Below is a stylesheet that isolates the problem.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="/">
<test>
<xsl:value-of select="
replace('30 dB','
([0-9])\s+
(
(
[hkMGTPdcmµnpf]?([mgsAKNJWCVFSTHLl])
| ([ch]a|t|dB)
| ((k|Ki|[MGTP]i?)?(B|bit))
| (KB?)
)
(\W|$)
)
','$1 $2','x')"
/>
</test>
</xsl:template>
</xsl:stylesheet>
I tested it in oXygen 15.2 using Saxon-PE 9.5.1.3 and with several
version of Saxon 9.6 and 9.7 for .NET on Windows 7.
It works fine in Saxon 9.4, it also works fine in 9.5 and 9.6/7 when
using the native regex engine with flags "!" resp. ";j" or ";n". So I
guess it has something to do with the new Jakarta-based regex
implementation introduced in 9.5.
The error only occurs when there is a match.
Could it be a bug, or is the regular expression invalid (or simply too
horrible to be processed by decent regex matchers)?
Thanks,
regards,
Tom De Herdt
Updated by Michael Kay over 8 years ago
Reproduced. The problem appears to occur when the replacement string of fn:replace ends with a single-digit group reference (like $2) and the regex contains more than 9 captured groups; so the code is looking to see if $2 is followed by another digit.
Updated by Michael Kay over 8 years ago
- Status changed from New to Resolved
- Applies to branch 9.6, 9.7, 9.8 added
- Fix Committed on Branch 9.6, 9.7, 9.8 added
Patch committed on the 9.6, 9.7, and 9.8 branches. (to REMatcher.java)
QT3 test case added: replace-54.
Updated by O'Neil Delpratt over 8 years ago
- % Done changed from 0 to 100
- Fixed in Maintenance Release 9.7.0.5 added
Bug fix applied in the 9.7.0.5 maintenance release. Leaving this bug open until fix is applied in the 9.6 maintenance release.
Updated by O'Neil Delpratt over 8 years ago
- Status changed from Resolved to Closed
- Fixed in Maintenance Release 9.6.0.9 added
- Fixed in Maintenance Release deleted (
9.7.0.5)
Bug fix applied in the Saxon 9.6.0.9 maintenance release.
Updated by O'Neil Delpratt over 8 years ago
- Fixed in Maintenance Release 9.7.0.5 added
Updated by O'Neil Delpratt over 7 years ago
- Applies to branch trunk added
- Applies to branch deleted (
9.8)
Updated by O'Neil Delpratt over 7 years ago
- Fix Committed on Branch trunk added
- Fix Committed on Branch deleted (
9.8)
Please register to edit this issue