Beehive
  1. Beehive
  2. BEEHIVE-949

netui compiler does not encode strings in validation config files

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.0
    • Component/s: NetUI
    • Labels:
      None
    • Environment:
      Windows XP. RC1 distribution from the v1/final branch.

      Description

      I am getting a runtime exception that looks like a malformed validation config file is being generated. Here is the snippet of the generated config file that looks problematic.
      <form-validation>
      <formset>
      <form name="listGroupForm">
      <field depends="mask,required" property="groupName">
      <arg0 key="groupNameRequired.displayName" resource="true"/>
      <var>
      <var-name>mask</var-name>
      <var-value>^[^' "=,\\<>#|&~?(){}%*]*$</var-value>
      </var>
      ....

      A snippet from the matching controller for this is:
      @Jpf.ValidatableBean
      ....
      validateMask = @Jpf.ValidateMask(regex="^[^' \"=,\\\\<>#|&~?(){}%*]*$")

      And the stack trace(s) I am seeing are:
      [exec] [ERROR] Digester - Parse Fatal Error at line 11 column 33: The content of elements must consist of well-formed character data or markup. <org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.>org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.

      [exec] at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
      [exec] at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:215)
      [exec] at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:386)
      [exec] at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
      [exec] at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1438)
      [exec] at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1723)
      [exec] at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
      [exec] at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
      [exec] at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
      [exec] at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
      [exec] at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
      [exec] at org.apache.commons.digester.Digester.parse(Digester.java:1591)
      [exec] at org.apache.commons.validator.ValidatorResources.<init>(ValidatorResources.java:159)
      [exec] at org.apache.struts.validator.ValidatorPlugIn.initResources(ValidatorPlugIn.java:237)
      [exec] at org.apache.struts.validator.ValidatorPlugIn.init(ValidatorPlugIn.java:162)
      [exec] at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:869)
      [exec] at org.apache.beehive.netui.pageflow.AutoRegisterActionServlet.registerModule(AutoRegisterActionServlet.java:553)
      [exec] at org.apache.beehive.netui.pageflow.AutoRegisterActionServlet.ensureModuleRegistered(AutoRegisterActionServlet.java:770)
      [exec] at org.apache.beehive.netui.pageflow.FlowControllerFactory.ensureModule(FlowControllerFactory.java:736)
      [exec] at org.apache.beehive.netui.pageflow.FlowControllerFactory.createPageFlow(FlowControllerFactory.java:209)
      [exec] at org.apache.beehive.netui.pageflow.FlowControllerFactory.createPageFlow(FlowControllerFactory.java:183)

      [exec] [ERROR] ValidatorPlugIn - Skipping all validation <org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.>org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
      [exec] at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1269)
      [exec] at org.apache.commons.digester.Digester.parse(Digester.java:1591)
      [exec] at org.apache.commons.validator.ValidatorResources.<init>(ValidatorResources.java:159)
      [exec] at org.apache.struts.validator.ValidatorPlugIn.initResources(ValidatorPlugIn.java:237)
      [exec] at org.apache.struts.validator.ValidatorPlugIn.init(ValidatorPlugIn.java:162)
      [exec] at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:869)
      [exec] at org.apache.beehive.netui.pageflow.AutoRegisterActionServlet.registerModule(AutoRegisterActionServlet.java:553)
      [exec] at org.apache.beehive.netui.pageflow.AutoRegisterActionServlet.ensureModuleRegistered(AutoRegisterActionServlet.java:770)
      [exec] at org.apache.beehive.netui.pageflow.FlowControllerFactory.ensureModule(FlowControllerFactory.java:736)
      [exec] at org.apache.beehive.netui.pageflow.FlowControllerFactory.createPageFlow(FlowControllerFactory.java:209)
      [exec] at org.apache.beehive.netui.pageflow.FlowControllerFactory.createPageFlow(FlowControllerFactory.java:183)

      1. j949-patch-code-only.txt
        3 kB
        Rich Feit
      2. j949-patch.txt
        60 kB
        Rich Feit

        Activity

        Hide
        Rich Feit added a comment -

        This is fixed in the branch (branches/v1/final) with revision 290880. I'd appreciate all the help I can get in verifying the fix, and in code reviewing the change. After it's verified/reviewed, I'll merge it into trunk.

        I'm going to attach two patches, for ease of review:

        • The full change, which is mostly an added EscapeXmlChars test.
        • The code-only change, to netui/src/compiler-core/org/apache/beehive/netui/compiler/model/XmlModelWriter.java.
        Show
        Rich Feit added a comment - This is fixed in the branch (branches/v1/final) with revision 290880. I'd appreciate all the help I can get in verifying the fix, and in code reviewing the change. After it's verified/reviewed, I'll merge it into trunk. I'm going to attach two patches, for ease of review: The full change, which is mostly an added EscapeXmlChars test. The code-only change, to netui/src/compiler-core/org/apache/beehive/netui/compiler/model/XmlModelWriter.java.
        Hide
        Rich Feit added a comment -

        The full patch. This is rooted at branches/v1/final/netui.

        Show
        Rich Feit added a comment - The full patch. This is rooted at branches/v1/final/netui.
        Hide
        Rich Feit added a comment -

        The code-only patch. This is rooted at branches/v1/final/netui.

        Show
        Rich Feit added a comment - The code-only patch. This is rooted at branches/v1/final/netui.
        Hide
        Rich Feit added a comment -

        Fixed with revision 291049, which merges the branches/v1/final fix into trunk. Thanks all for the help in identifying this and verifying the fix.

        Show
        Rich Feit added a comment - Fixed with revision 291049, which merges the branches/v1/final fix into trunk. Thanks all for the help in identifying this and verifying the fix.
        Hide
        Alejandro Ramirez added a comment -

        Verified fixed. Executed a tests that included a conditional forwards as follows:
        @Jpf.Controller(
        @Jpf.SimpleAction(
        name="conditional",
        conditionalForwards={
        @Jpf.ConditionalForward(condition="$

        {layoutChoice<2}

        ", tilesDefinition="conditional1.page"),
        @Jpf.ConditionalForward(condition="$

        {layoutChoice<3}

        ", tilesDefinition="conditional2.page")
        }))

        and now the genereted struts config file correctly encodes the "<" character as follows:
        <action className="org.apache.beehive.netui.pageflow.config.PageFlowActionMapping" parameter="tiles.TilesController" path="/conditional" scope="request" type="org.apache.beehive.netui.pageflow.internal.FlowControllerAction" validate="false">
        <set-property property="simpleAction" value="true"/>
        <set-property property="defaultForward" value="_defaultForward"/>
        <set-property property="conditionalForwards" value="_anon1:$

        {layoutChoice<2}

        ;_anon2:$

        {layoutChoice<3}

        ;"/>
        <forward name="_defaultForward" path="conditional3.page"/>
        <forward name="_anon1" path="conditional1.page"/>
        <forward name="_anon2" path="conditional2.page"/>
        </action>

        Show
        Alejandro Ramirez added a comment - Verified fixed. Executed a tests that included a conditional forwards as follows: @Jpf.Controller( @Jpf.SimpleAction( name="conditional", conditionalForwards={ @Jpf.ConditionalForward(condition="$ {layoutChoice<2} ", tilesDefinition="conditional1.page"), @Jpf.ConditionalForward(condition="$ {layoutChoice<3} ", tilesDefinition="conditional2.page") })) and now the genereted struts config file correctly encodes the "<" character as follows: <action className="org.apache.beehive.netui.pageflow.config.PageFlowActionMapping" parameter="tiles.TilesController" path="/conditional" scope="request" type="org.apache.beehive.netui.pageflow.internal.FlowControllerAction" validate="false"> <set-property property="simpleAction" value="true"/> <set-property property="defaultForward" value="_defaultForward"/> <set-property property="conditionalForwards" value="_anon1:$ {layoutChoice<2} ;_anon2:$ {layoutChoice<3} ;"/> <forward name="_defaultForward" path="conditional3.page"/> <forward name="_anon1" path="conditional1.page"/> <forward name="_anon2" path="conditional2.page"/> </action>

          People

          • Assignee:
            Alejandro Ramirez
            Reporter:
            Jim Cummings
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development