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

Query Parameters in Multipart Requests not working in v7 M6

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 7.0.0
    • 7.0.0
    • None
    • None

    Description

      One of the changes in https://github.com/apache/struts/pull/861 broke query parameters in multipart requests. Their values are being lost.

      This is the old implementation, which returns null if the parameter doesn't exist.

      public String[] getParameterValues(String name) {
          List<String> v = params.get(name);
          if (v != null && !v.isEmpty()) {
              return v.toArray(new String[0]);
          }
      
          return null;
      } 

       

      And this is the new implementation, which returns an empty array in that case.

      public String[] getParameterValues(String name) {        
          return parameters.getOrDefault(name, Collections.emptyList())
                  .toArray(String[]::new);
      }

       

      This method in MultiPartRequestWrapper is expecting null to be returned in that case.

      public String[] getParameterValues(String name) {
          return ((multi == null) || (multi.getParameterValues(name) == null)) ? super.getParameterValues(name) : multi.getParameterValues(name);
      }

       

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              criderp Philip Crider
              Votes:
              0 Vote for this issue
              Watchers:
              2 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 - 40m
                  40m