Project

Profile

Help

Bug #2735

closed

ArrayIndexOutOfBoundsException while evaluating regular expression

Added by Michael Kay almost 8 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XPath conformance
Sprint/Milestone:
Start date:
2016-05-05
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.6, 9.7, trunk
Fix Committed on Branch:
9.6, 9.7, trunk
Fixed in Maintenance Release:
Platforms:

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&#xA0;$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

Actions #1

Updated by Michael Kay almost 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.

Actions #2

Updated by Michael Kay almost 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.

Actions #3

Updated by O'Neil Delpratt almost 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.

Actions #4

Updated by O'Neil Delpratt almost 8 years ago

  • Sprint/Milestone set to 9.7.0.5
Actions #5

Updated by O'Neil Delpratt almost 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.

Actions #6

Updated by O'Neil Delpratt almost 8 years ago

  • Fixed in Maintenance Release 9.7.0.5 added
Actions #7

Updated by O'Neil Delpratt almost 7 years ago

  • Applies to branch trunk added
  • Applies to branch deleted (9.8)
Actions #8

Updated by O'Neil Delpratt almost 7 years ago

  • Fix Committed on Branch trunk added
  • Fix Committed on Branch deleted (9.8)

Please register to edit this issue

Also available in: Atom PDF