question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[HTTPClient] Incorrect URI encoding for params

See original GitHub issue

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Context

HTTPClient

Current behavior

When adding a param to a HTTP GET request, a colon : is not encoded to its UTF-8 value %3A.

Expected behavior

When adding a param to a HTTP GET request, a colon : is encoded to it’s UTF-8 value %3A.

Minimal reproduction of the problem with instructions

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { url } from 'config/main';

@Injectable()
export class ExampleService {
  constructor(private http: HttpClient) { }

  makeRequest(): void {
    return this.http.get('http://url.com', {
      params: {
        param: '$:test',
      },
    });
  }
}

Expected request

http://url.com?param=%24%3atest

Actual request

http://url.com?param=%24:atest

What is the motivation / use case for changing the behavior?

It seems as though the encodeURI function is being used on parameters in order to translate them to UTF-8 strings as opposed to the more appropriate encodeURIComponent function

Environment


Angular version: X.Y.Z


Browser:
- [x] Chrome (desktop) version 64.0.3282.119
 
Others:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

18reactions
lucipacurarcommented, Jun 14, 2018

I’m still experiencing this bug on Angular 6.0.3. Isn’t it fixed already?

In my case I’m sending a date string to the server: 2018-06-14T10:20:42+03:00 as a URL param and it doesn’t get encoded at all.

1reaction
henriquezagocommented, May 10, 2019

I’m having problems with the + character.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - HttpClient encoding of URL parameters containing a
and I'm trying to get an entity from a DotNetCore web service by specifying it's id in the URL.
Read more >
How To Fix Angular HttpClient Not Escaping URL Parameters
Strangely, I noticed my query parameter was not encoded as expected, which made the API return wrong results. This behaviour might be confusing: ......
Read more >
Using URL encoding to handle special characters in a ...
The <space> character needs to be encoded because it is not a valid URL character. Also, some characters, such as "~" might not...
Read more >
HTTP Client doesn't url encode plus signs : IDEA-239229
HTTP Client treats + as an encoded space and doesn't encode it the second time. As a workaround you can replace + with...
Read more >
URL (GWT Javadoc)
com.google.gwt.http.client.URL ... Parameters: encodedURL - string containing encoded URL encoded sequences; Returns: string with no encoded URL encoded ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found