Struts 2
  1. Struts 2
  2. WW-3066

RegexFieldValidator not working correctly on IBM JVM - xml validation files

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1.6
    • Fix Version/s: Future
    • Component/s: XML Validators
    • Labels:
      None
    • Environment:

      IBM WAS 7.0

      Description

      We use -validation.xml files in our struts2 web application. Validation worked fine on Tomcat but since we migrated to Websphere 7.0, we have noticed strange behaviour of the XWork Validator framework. After some debugging we found, that the reason was RegexFieldValidator.getTextValue(Element valueEle) method.

      On IBM JVM, XML expressions containing XML entities (such as & or > ) are parsed as separate nodes, so following configuration:

      <field-validator type="fieldexpression">
      <param name="expression">( (placeId != null && placeId > 0))</param>
      <message>String required</message>
      </field-validator>

      resulted in following Nodes being bassed to RegexFieldValidator.getTextValue() method:
      ( (placeId != null
      &
      &
      placeId
      >
      0))

      After merging those nodes, getTextValue returned this String: "( (placeId != null & & placeId > 0))."

      Additional space were added added between nodes, which broke the whole expression. The same behaviour was noticed when using CDATA tag.

      Our quick-fix was to override the RegexFieldValidator.getTextValue() to delegate to DomUtils.getTextValue() method.

      Best regards.

        Issue Links

          Activity

          Hide
          Lukasz Lenart added a comment -

          Seems to be solved already, could you check against the latest version ?

          Show
          Lukasz Lenart added a comment - Seems to be solved already, could you check against the latest version ?

            People

            • Assignee:
              Unassigned
              Reporter:
              Tomasz Filak
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Development