0

I have this strange situation with one of my clients. Apparently their website works with URL's like this:

http://example.com/msweb.nsf/pages/Books!OpenDocument&vw=Class&f1=books

If I send this to parse_url() call in PHP, then it converts & characters to & for the returned array keyword 'path'. It doesn't do this for 'query' part, if such exists, only for 'path'.

It does this because it considers the whole part as path (since they use ! instead of ? as query separator). Is there a reason why such a conversion takes place for path (I would consider & as invalid for path as & alone) and is there a standard I could refer the client to so they could fix the problem?

Current situation is that we create URL shorteners and utilize parse_url() as method to gather details about the URL, yet currently it breaks with that specific client because of the ampersand conversion.

I tried to search for this in parse_url() documentation, but didn't find anything referring to &

deceze
  • 510,633
  • 85
  • 743
  • 889
kingmaple
  • 4,200
  • 5
  • 32
  • 44
  • You're not saying what it converts them *to*?... Anyway, that is not a valid URL, so it's no wonder `parse_url()` would mess it up. – Pekka May 24 '12 at 07:51
  • I figured it is not a valid URL, but is there a URL validator somewhere or some documentation I could refer to? I didn't find information on this, despite searching. Wiki also didn't help. – kingmaple May 24 '12 at 07:52
  • You could try `filter_var()` (http://www.php.net/manual/en/function.filter-var.php) with `VALIDATE_URL` but I don't know what it'll do in this case - you'd have to try out. – Pekka May 24 '12 at 07:55
  • Could you not try replacing the `!` with a `?` before you send it to `parse_url`? – fire May 24 '12 at 08:23
  • Apparently this was client error. Their web system accepts ! for query string for some reason. And conversion was made by CKEditor and not PHP. So two problems. I notified client of their web servers weird behavior. Thanks everybody! – kingmaple May 24 '12 at 09:52

0 Answers0