Uploaded image for project: 'Struts 1'
  1. Struts 1
  2. STR-2997

[validator] validwhen strings don't work right

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.2.4, 1.2.9
    • 1.3.7
    • Core
    • None

    Description

      I originally noticed this problem with struts 1.2.4, but upgrading to 1.2.9 didn't fix it. I can't upgrade to 1.3.5 right now so I don't know if it still exists there or not.

      It seems that the content of string that is usable by the validwhen validator is oddly limited. It only appears to allow letters and a few other random characters. This makes the validator mostly useless.

      I tried to define a field validation using the validwhen validator:

      <field property="myfield" depends="validwhen">
      <arg0 key="prop.myfield"/>
      <var>
      <var-name>test</var-name>
      <var-value>(otherfield != "foo:bar")</var-value>
      </var>
      </field>

      I got an error that looked like this:

      ValidWhen Error for field ' myfield' - line 1:20: expecting ''', found ':'

      I tried it with a few other characters, but there didn't seem to be any pattern to what is allowed and what isn't.

      not ok:
      :@#$%^&;,/+

      ok:
      *().<>-_=

      (not a comprehensive list, I didn't try everything)
      I tried using both single and double quotes, but it didn't seem to make a difference.
      This problem seems to have been mentioned on the mailing lists a few times, but I wasn't able to find any answers.

      Looking at the definition of STRING_LITERAL in ValidWhenParser.g, it seems like any non-quote character should be allowed:

      STRING_LITERAL : ('\'' ('\'')+ '\'') | ('\"' ('\"')+ '\"') ;

      Attachments

        1. STR-2997-test.patch
          0.7 kB
          Jira Report User
        2. STR-2997-fix.patch
          0.5 kB
          Jira Report User

        Activity

          People

            Unassigned Unassigned
            erh Eric Haszlakiewicz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: