Bug 564747 - Empty-valued query parameters in request URLs are returned twice, once with an empty value and once with a null value
Summary: Empty-valued query parameters in request URLs are returned twice, once with a...
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Compendium (show other bugs)
Version: 4.14   Edit
Hardware: All All
: P3 critical (vote)
Target Milestone: 4.17 M1   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2020-06-29 13:15 EDT by John Vasta CLA
Modified: 2020-10-26 15:04 EDT (History)
2 users (show)

See Also:


Attachments
servlet illustrating behavior of empty-valued parameters (7.72 KB, application/x-zip-compressed)
2020-06-29 13:15 EDT, John Vasta CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Vasta CLA 2020-06-29 13:15:30 EDT
Created attachment 283433 [details]
servlet illustrating behavior of empty-valued parameters

In an application that is deployed in a JEE servlet container using the Equinox bridge servlet, an incoming request URI with an empty-valued query parameter (e.g. "?param=") results in two values returned by HttpServletRequest#getParameterMap, one with the value being an empty string (which is correct), and one with a null value (which is incorrect). According to the JEE servlet specifications, a null value is only returned for parameters that do not exist at all in the request URI query string. If a parameter name is followed by an equals sign but no value, the parameter value is the empty string.

This breaks our applications significantly, because we have services with required parameters where a single parameter instance is required, but the value is allowed to be empty. When our code gets a null value, that means the parameter was not specified by the client, which is an error.

I'm adding a zip of a servlet project illustrating the problem; it can be deployed as an embedded Equinox application. (It is a variant of the example I attached to bug 562843).

It appears this defect was surfaced by the fix for bug 500783. The actual problem is in the DispatchTargets#queryStringToParameterMap method - it is returning null for empty-valued parameters. Then the DispatchTargets#getParameterMap method merges those values with the values from the incoming request's getParameterMap result (which contains the correct empty string value), resulting in two values for the same parameter, one being null.
Comment 1 Eclipse Genie CLA 2020-06-29 14:44:25 EDT
New Gerrit change created: https://git.eclipse.org/r/c/equinox/rt.equinox.bundles/+/165580
Comment 3 Thomas Watson CLA 2020-06-29 15:32:16 EDT
Thanks, I added a testcase and a fix for 4.17 release.
Comment 4 Eclipse Genie CLA 2020-08-31 09:29:25 EDT
New Gerrit change created: https://git.eclipse.org/r/c/equinox/rt.equinox.bundles/+/168477
Comment 6 Eclipse Genie CLA 2020-10-26 13:39:33 EDT
New Gerrit change created: https://git.eclipse.org/r/c/equinox/rt.equinox.bundles/+/171314