Is a url query parameter valid if it has no value?

Is a url like http://example.com/foo?bar valid?

I’m looking for a link to something official that says one way or the other. A simple yes/no answer or anecdotal evidence won’t cut it.

Getting Query Parameter from a URL which inturn has some URL with Query parameters

I’ve the following URL http://somesite/somepage.aspx I pass a query parameter value which has another URL with query parameters like this. http://somesite/somepage.aspx?pageURL=http://someothersite/s

How to read query parameter value from URL using perl command

In shell, I need to extract specific query parameter from URI. I tried to play around with this to get offset value echo /mypath/index.php?offset=20&query=uro | perl -MURI -le ‘chomp($url = &l

query string parameter without value, only key

i have question about query string in asp.net: standart query string with query string parameter is www.mysity.url?key1=value1&key2=value2, but i need only check has query string key or not…ye

Is passing a query string parameter (whose value is null) without the equals sign valid?

Variation 1: file.jsp?parameter1=&parameter2=abc Variation 2: file.jsp?parameter1&parameter2=abc I know Variation 1 is considered valid, but is variation 2 considered valid? Specifically,

Is this a valid url parameter in jquery.ajax()?

Is this a valid url parameter in jquery.ajax(), <script type=text/javascript> $(document).ready(function() { getRecordspage(); }); function getRecordspage() { $.ajax({ type: POST, url: http

Is using & as a Query Parameter delimiter valid?

If I have a URL with query parameters, is it valid to escape the & query parameter delimiter? Ex. <a href=/foo.html?cat=meow&dog=woof>go</a> vs <a href=/foo.html?cat=meow&

CodeIgniter doesn’t allow ‘0’ as a valid URL parameter?

Why doesn’t CI allow the number zero as a valid URL parameter?! To rule out some mistake in my code, I have a clean install of PyroCMS, and just display the seconde URL parameter. Everything works ex

Twitter button ‘url’ parameter does not contain a valid URL

I am passing this url http://new.wadja.com/petty01#bad religion to twitter button and I receive ‘url’ parameter does not contain a valid URL. Below I have an example of my tweet button — hmm…s

The provided value for the input parameter ‘redirect_uri’ is not valid

I keep receiving this error from windows live The provided value for the input parameter ‘redirect_uri’ is not valid. The expected value is ‘https://login.live.com/oauth20_desktop.srf’ or a URL which

Distinguish empty value from empty string (“”) in Url query parameter

How to distinguish URL without value like this /url?var from /url?var= in Spring MVC? Method HttpServletRequest::getParameterMap() in controller returns in both ways. I need this to separate com

Answers

Yes, it is valid.

If one simply want to check if the parameter exists or not, this is one way to do so.

“The “http” scheme is used to locate network resources via the HTTP protocol. This section defines the scheme-specific syntax and semantics for http URLs.” http://www.w3.org/Protocols/rfc2616/rfc2616.html

http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]] 

So yes, anything is valid after a question mark. Your server may interpret differently, but anecdotally, you can see some languages treat that as a boolean value which is true if listed.

They’re perfectly valid. You could consider them to be the equivalent of the big muscled guy standing silently behind the mob messenger. The guy doesn’t have a name and doesn’t speak, but his mere presence conveys information.

  • Valid to the URI RFC
  • Likely acceptable to your server-side framework/code

The URI RFC doesn’t mandate a format for the query string. Although it is recognized that the query string will often carry name-value pairs, it is not required to (e.g. it will often contain another URI).

3.4. Query

The query component contains non-hierarchical data that, along with data in the path component (Section 3.3), serves to identify a resource within the scope of the URI’s scheme and naming authority (if any). …

… However, as query components are often used to carry identifying information in the form of “key=value” pairs and one frequently used value is a reference to another URI, …

HTML establishes that a form submitted via HTTP GET should encode the form values as name-value pairs in the form “?key1=value1&key2=value2…” (properly encoded). Parsing of the query string is up to the server-side code (e.g. Java servlet engine).

You don’t identify what server-side framework you use, if any, but it is possible that your server-side framework may assume the query string will always be in name-value pairs and it may choke on a query string that is not in that format (e.g. ?bar). If its your own custom code parsing the query string, you simply have to ensure you handle that query string format. If its a framework, you’ll need to consult your documentation or simply test it to see how it is handled.

isindex from HTML5 allows a form submission to generate such an URL, providing further evidence that it is valid for HTML. E.g.:

<form action="#isindex" class="border" id="isindex" method="get">
  <input type="text" name="isindex" value="bar"/>
  <button type="submit">Submit</button>
</form>

generates an URL of type:

?bar

Standard: https://www.w3.org/TR/html5/forms.html#naming-form-controls:-the-name-attribute