Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-5065

AbstractMatcher adds values to the map passed into replaceParameters

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5.22
    • Fix Version/s: 2.5.25, 2.6
    • Component/s: None
    • Labels:
      None

      Description

      There is a bug with the AbstractMatcher#replaceParameters method in struts/core/src/main/java/com/opensymphony/xwork2/config/impl/AbstractMatcher.java (currently lines 153-170). As the function currently works it will return a map that has more keys than the "orig" map that is passed into it. For example, assume that I have the following config defined in my struts.xml file:

      <package name="test" namespace="/test">
        <action name="{paramOne}/{paramTwo} class="org.MyActionClass" method="execute">
          <result name="success" type="stream">
            <param name="inputName">random</param>
          </result>
        </action>
      </package>

      If you send a request to "/test/uno/dos", this will trigger code in ActionConfigMatcher (lines 95-103) that will construct the ResultConfig objects to be used later on. At one point you are going to be making a call to AbstractMatcher#replaceParameters with something that looks like the following:

      orig:
        "inputName" -> "random"

      vars:
        "0" -> "uno/dos"
        "paramOne" -> "uno"
        "1" -> "uno"
        "paramTwo" -> "dos"
        "2" -> "dos"

      The result of this will be a map that looks like:
        "inputName" -> "random"
        "paramOne" -> "uno"
        "paramTwo" -> "dos"

      The bug is that "paramOne" and "paramTwo" should not be in the return map.

      For the most part this but won't cause any problems but it will cause some performance problems in certain situations when trying to set these parameters on the results objects that aren't expecting them.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              alextkaiser Alex Kaiser
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1.5h
                1.5h