Results 1 to 1 of 1

Thread: URL-encoding control characters

  1. #1
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default URL-encoding control characters

    EDIT: Sorry, I was using an undefined variable. This bug was somewhere between the chair and the keyboard.

    PHP is getting me frustrated with their (raw)urlencode function. I have an email form, and I'm trying to prepare for the mail function's failure by giving an error message which contains a mailto link. The link passes the subject and body to the email client via GET - admittedly not a critical feature, but AFAICT it should work perfectly.

    Quote Originally Posted by http://www.faqs.org/rfcs/rfc1738
    URLs are written only with the graphic printable characters of the US-ASCII coded character set. The octets 80-FF hexadecimal are not used in US-ASCII, and the octets 00-1F and 7F hexadecimal represent control characters; these must be encoded.
    My problem is that the newline characters (carriage return and linefeed) aren't encoded, even though they (0D and 0A) are included in 00-1F. I tried replacing them myself with their codes (%0d and %0a), but both str_replace and the other two functions just spit out an empty string when they hit these characters. That is, unless I type them directly into a double-quoted string.

    Does anyone have an idea for how to work around this? (I think this is the third PHP bug I've found since I finally fixed my computer a few days ago.)
    Last edited by Jesdisciple; 06-03-2009 at 07:39 PM. Reason: d'oh...
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •