0

i could be happy if some one give me a solution,here i passed parameter in URL for sending an mail but line feed encoding code %0D and %0A not working.please help me.

stuff is

page_id=93&emailID=abcd@xyz.com&phoneNo=&subject=I Need Help - Safety Request via iHope&body=From: hh via iHope%0AMessage: I need help, call 911.%0AI am here: http://bit.ly/1qWrgfT%0AGPS Location appears to be: %0A-35, qwert qwerty yuioop, asdfghh, vfgrt poiuyt-%0A-380020%0A&from=From iHope support

  • can you post the code please – NavinRaj Pandey Sep 16 '14 at 09:01
  • Could it be that you're using Unix-style line terminator (%0A) instead of Windows-style ones (%0D%0A)? Also, as Alexander pointed out, make sure to encode the entire URL for non-safe characters. – PeterK Sep 16 '14 at 09:21
  • i have to try both %0D%0A or %0A but its not working line feed to received mail. – Sabir Kharodiya Sep 16 '14 at 09:23
  • Ok, can you please tell us more about how this link is used? I see it's not a `mailto:` URL, so I suppose you send this over to a web service or something. If that's the case, any chance you can debug the receiving end? – PeterK Sep 16 '14 at 09:50
  • yes, i got the whole mail in one string,but i want to mail in formatted text but line feed not working. – Sabir Kharodiya Sep 16 '14 at 10:08
  • So is this an URL you send in a web request (i.e. http://example.org/some-service?page_id=...)? If it is, does the receiving end handle line breaks at all? – PeterK Sep 16 '14 at 10:12
  • Yes URL is this,here i want receiving out put like this I need help, call 911 I am here: http://bit.ly/1qWrgfT GPS Location appears to be: 35, Shidhnath Mahadev Mandir Marg, Premchand Nagar Society, Satellite Ahmedabad, Gujarat- **Just Like** – Sabir Kharodiya Sep 16 '14 at 10:22

1 Answers1

0

According to RFC 3986, section 2.1:

A percent-encoding mechanism is used to represent a data octet in a
component when that octet's corresponding character is outside the
allowed set or is being used as a delimiter of, or within, the
component. A percent-encoded octet is encoded as a character
triplet, consisting of the percent character "%" followed by the two
hexadecimal digits representing that octet's numeric value. For
example, "%20" is the percent-encoding for the binary octet
"00100000" (ABNF: %x20), which in US-ASCII corresponds to the space
character (SP). Section 2.4 describes when percent-encoding and
decoding is applied.

  pct-encoded = "%" HEXDIG HEXDIG

So, %D%A is incorrect. %0D%0A is correct.

According to your edit, if you use percent-encoding, you should encode the whole URI, including spaces and the rest. not only CR/LF chars. See [this post][2] on how to encode URL.

Community
  • 1
  • 1
Alexander Zhak
  • 9,140
  • 4
  • 46
  • 72