Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 334 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to encode the plus (+) symbol in a URL

#1
The URL link below will open a new Google mail window. The problem I have is that Google replaces all the plus (+) signs in the email body with blank space. It looks like it only happens with the `+` sign. How can I remedy this? (I am working on a ASP.NET web page.)

[To see links please register here]

subject&body=Hi there+Hello there

(In the body email, "Hi there+Hello there" will show up as "Hi there Hello there")


Reply

#2
<p>It's safer to always percent-encode all characters except those defined as "unreserved" in RFC-3986.</p>

unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"

<p>So, percent-encode the plus character and other special characters.</p>

<p>The problem that you are having with pluses is because, according to RFC-1866 (HTML 2.0 specification), paragraph 8.2.1. subparagraph 1., "The form field names and values are escaped: space characters are replaced by `+', and then reserved characters are escaped"). This way of encoding form data is also given in later HTML specifications, look for relevant paragraphs about application/x-www-form-urlencoded.</p>
Reply

#3
Just to add this to the list:

```
Uri.EscapeUriString("Hi there+Hello there") // Hi%20there+Hello%20there
Uri.EscapeDataString("Hi there+Hello there") // Hi%20there%2BHello%20there
```

See

[To see links please register here]


Usually you want to use `EscapeDataString` which does it right.
Reply

#4
If you want a plus `+` symbol in the body you have to encode it as `2B`.

For example:
[Try this][1]

[1]:

[To see links please register here]

Reply

#5
Generally if you use .NET API's - `new Uri("someproto:with+plus").LocalPath` or `AbsolutePath` will keep plus character in URL. (Same `"someproto:with+plus"` string)


but `Uri.EscapeDataString("with+plus")` will escape plus character and will produce `"with%2Bplus"`.

Just to be consistent I would recommend to always escape plus character to `"%2B"` and use it everywhere - then no need to guess who thinks and what about your plus character.

I'm not sure why from escaped character `'+'` decoding would produce space character `' '` - but apparently it's the issue with some of components.
Reply

#6
In order to encode a `+` value using JavaScript, you can use the `encodeURIComponent` function.

Example:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

var url = "+11";
var encoded_url = encodeURIComponent(url);
console.log(encoded_url)

<!-- end snippet -->




Reply

#7
The `+` character has a special meaning in [the query segment of] a URL => it means whitespace: ` `. If you want to use the literal `+` sign there, you need to URL encode it to `%2b`:

```lang-none
body=Hi+there%2bHello+there
```

Here's an example of how you could properly generate URLs in .NET:

var uriBuilder = new UriBuilder("https://mail.google.com/mail");

var values = HttpUtility.ParseQueryString(string.Empty);
values["view"] = "cm";
values["tf"] = "0";
values["to"] = "[email protected]";
values["su"] = "some subject";
values["body"] = "Hi there+Hello there";

uriBuilder.Query = values.ToString();

Console.WriteLine(uriBuilder.ToString());

The result:

>

[To see links please register here]


Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through