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

Please register to edit this issue

Also available in: Atom PDF