34739

Meta refresh with semicolon

I have semicolon as query string separator in my urls instead of and (&). My problem is that when I try to do a meta refresh to a url with semicolon in query string it will translate it to %253b instead. So when forwarded, I can't read the query string parameters as the separator is not there anymore. example:

http://domain.com/?foo=1;bar=2

becomes:

http://domain.com?foo=1%253bbar=2

How can I solve this, so it doesn't translate the semicolon when doing a meta refresh?

Grateful for any help!

Answer1:

The problem is that the query string is being encoded twice, when it needn’t be encoded at all. This is probably because the code that encodes and decodes the query string (which you don’t mention) is expecting the traditional ampersand (&) query string separator and feels free to encode everything else.

Original: foo=1;bar=2

1st encoding (semicolon → %3B): foo=1%3bbar=2

2nd encoding (percent → %25): foo=1%253bbar=2

Answer2:

UPDATE

As pointed in the comments, ; is a valid character for an url which is reserved for a purpose not specified in the RFC. Like pointed by danorton in its own answer, the problem seems to be a double encoding of the URL.

As it is, it is impossible to provide a solution without more information about the environment and the exact situation when the problem occurs.

However, like stated in my previous wrong answer, I stay on my position concerning the use of & as a separator. Using something else is asking for problems in my opinion.

my "wrong" answer

I don't think ; is a valid character for an url, so it seems normal to me that it get encoded. There's a reason & is used, why do you want to change that ?

Doing something like this is asking for problems. It's already pretty hard to get things working on all the browsers and OSes combination, why makes things even harder ?

If you want to stick with this and you're using PHP, have a look at urlencode() and parse-url()

Answer3:

Using single quotes for the url will fix the issue.

<meta http-equiv="refresh" content="0;URL='http://domain.com/?foo=1;bar=2'">

Most browsers (Firefox, Chrome, Safari, Opera) will probably redirect to the full url atm without the quotes, but Internet Explorer (IE10 too) will discard the part after the second semicolon without the single quotes.

<hr>

Uri Syntax RFC3986

Recommend

  • Messaging Protocol
  • Pass javascript variable into php code
  • Special Characters on Console
  • Ignoring certain characters while looping through CSV rows
  • Violates RFC 2109: host > minus domain may not contain any dots
  • Converting C-Strings from Local Encoding to UTF8
  • url scheme for ssh: Calling command on remote host
  • How to mock springSecurityService in unit tests using grails
  • DELETE FROM … reporting syntax error at or near “.”
  • Convert hex to utf in Python
  • Python-3 Request parameter encoding error
  • How to remove trailing space from marquee?
  • SQL Server 2005, Caches and all that jazz
  • Process.PrivateMemorySize64 returning committed memory instead of private
  • How to edit css for jquery datepicker prev/next buttons?
  • Is it possible to specialize on a static lifetime?
  • Retrieving a contacts notes
  • Special chars in Amazon S3 keys?
  • Encode Byte array to JPEG image in Objective-C
  • Using HTML/CSS for UI in XNA?
  • Serve file to user over http via php
  • C function strchr - How to calculate the position of the character?
  • How do I retrieve the user information of a user authenticated with Apache's mod_ldap?
  • Trying to get the char code of ENTER key
  • xcode don't localize specific strings
  • Unable to decode certificate at client new X509Certificate2()
  • Do I need to reset a Perl hash index?
  • preg_replace Double Spaces to tab (\\t) at the beginning of a line
  • Use of this Javascript
  • Why does access(2) check for real and not effective UID?
  • ilmerge with a PFX file
  • Apache 2.4 and php-fpm does not trigger apache http basic auth for php pages
  • How can I use Kendo UI with Razor?
  • Release, debug version and Authorization Google?
  • Is there a mandatory requirement to switch app.yaml?
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • Why joiner is not used after Sequence generator or Update statergy
  • How does Linux kernel interrupt the application?
  • Running Map reduces the dimensions of the matrices
  • git trying to push non-existent file … after clearing cache