Empty URI query string parameters: "a = & b =" compared to "a & b"

Should the following URLs be considered functionally equivalent?

http://example.com/foo?a=&b= http://example.com/foo?a&b 

This happened when a user of the Drupal module that I wrote that parses separately and then rewrites the URI noticed that the code sometimes calls the String Parts request for modification in unexpected ways due to the way some of the basic PHP functions behave. For instance:

 parse_str("a&b", $values); print http_build_query($values); a=&b= 

Is this something I should worry about?

Edit, so SO ceases to complain that this question is similar to another: the question is whether it can be assumed that "no value for X" and "empty value for X" are equivalent, and not the "no value" style is syntactically correct (which she is).

+6
source share
1 answer

RFC 3986 Uniform Resource Identifier (URI): The general syntax has nothing to say about the structure of the query string, except for how to handle characters such as ? . So strictly speaking, your two examples of urls are different. Of course, an application that receives these query strings may treat them as functionally equivalent, but this is not something you can define from a single URL.

+1
source

Source: https://habr.com/ru/post/911626/


All Articles