Skip to content

Can't catch the exception from ActivatedRoute.queryParams when using % in the URL - causes app to crash #21468

Closed

Description

@shmaram

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

Current behavior

Using ActivatedRoute.queryParams with url the includes % it throws an exception that can't be catched anywhere and causing the app to crash.

Expected behavior

To be able to catch this kind of error and to be able to keep working with the app

Minimal reproduction of the problem with instructions

http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).
go to : https://embed.plnkr.co/tUMGOtW39iMDYKHcv1hm/
then add layout=!@#$%^&*() so that the new URL will be
https://embed.plnkr.co/tUMGOtW39iMDYKHcv1hm/?layout=!@#$%^&*()

Error found :
URIError: URI malformed
at decodeURIComponent ()
at Ye (vendor.6b9be0480d04ab9c9c6c.js:6)
at tn.$$parse (vendor.6b9be0480d04ab9c9c6c.js:6)
at tn.$$parseLinkUrl (vendor.6b9be0480d04ab9c9c6c.js:6)
at an.$get (vendor.6b9be0480d04ab9c9c6c.js:6)
at Object.a [as invoke] (vendor.6b9be0480d04ab9c9c6c.js:6)
at vendor.6b9be0480d04ab9c9c6c.js:6
at r (vendor.6b9be0480d04ab9c9c6c.js:6)
at i (vendor.6b9be0480d04ab9c9c6c.js:6)
at Object.a [as invoke] (vendor.6b9be0480d04ab9c9c6c.js:6)

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

By fixing this issue adding % in the URL will not crush the application

Environment


Angular version: 4.0.0


Browser:
- [ X ] Chrome (desktop) version 63.0.3239.132
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Activity

  1. added this to the Backlog milestone on Jan 23, 2018
  2. sod commented on Feb 8, 2018

    @sod
    Contributor

    Still an issue / angular 5.2.3.

    In angular.js the router parses the uri component in a try/catch, thus ignoring invalid parts of the URL.

    angular 5 doesn't try/catch. If decodeURIComponent throws (just like decodeURIComponent('%') does), then the app stops functioning.

  3. modified the milestones: Backlog, needsTriage on Feb 26, 2018
  4. skryvets commented on Apr 7, 2018

    @skryvets

    I'm working on the solution and will submit the PR in near future.

  5. added a commit that references this issue on Apr 18, 2018
    a04a1f8
  6. feynmanloo commented on Jun 23, 2018

    @feynmanloo

    Still an issue / angular 6.0.0

  7. added a commit that references this issue on Jul 11, 2018
    2d4f4b5
  8. added 2 commits that reference this issue on Jul 30, 2018
    5399c17
  9. muriloqr commented on Apr 9, 2019

    @muriloqr

    Still an issue for me, here is the workaround:

    import { UrlTree ,DefaultUrlSerializer, UrlSerializer } from '@angular/router';
    
    export class cleanUrlSerializer extends DefaultUrlSerializer {
    public parse(url: string): UrlTree {
      function cleanUrl(url) {
          return unescape(url);
      }
     
      return super.parse(cleanUrl(url));
      }
    }
    

    Add provider:

    {
      provide: UrlSerializer,
      useClass: cleanUrlSerializer
    }
    
  10. angular-automatic-lock-bot commented on Sep 14, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  11. locked and limited conversation to collaborators on Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions