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

AliasInterceptor doesn't properly handle Parameter.Empty

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.22
    • Fix Version/s: 2.5.25, 2.6
    • Component/s: Core Interceptors
    • Labels:
      None

      Description

      As I reported on the mailing list, there is a bug with AliasInterceptor not handling the Parameter.Empty that is returned from HttpParameters.get(). Since HttpParameters.get() always returns a non-null value, the Evaluated object is treated as always being defined, which results in the empty value being set incorrectly on the stack.

      The bug was originally introduced here:

      https://github.com/apache/struts/commit/787f2f96eb9f1bb3c8012ab42aa222ae6286a91a#diff-b7b7c87c1012088e79dcc5a7bd9e8127R168

      The fix is easy; this code:

      // workaround
      HttpParameters contextParameters = ActionContext.getContext().getParameters();
      if (null != contextParameters) {
          value = new Evaluated(contextParameters.get(name));
      }

      needs to be updated to:

      // workaround
      HttpParameters contextParameters = ActionContext.getContext().getParameters();
      if (null != contextParameters) {
          Parameter param = contextParameters.get(name);
          value = new Evaluated(param.isDefined() ? param : null);
      } 

      This way, it ensures the Evaluated value is only defined when appropriate.

       

        Attachments

          Activity

            People

            • Assignee:
              yasserzamani Yasser Zamani
              Reporter:
              lenzbd Brian Lenz
            • Votes:
              1 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 - 1h
                1h