aurelia / aurelia/route-recognizer

Throws exception when handling routes containing new-line characters or carriage returns

Open
#63 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
26
Forks
25
PR merge metrics
No merged PRs in 30d

Description

**I'm submitting a bug report**

* **Library Version:**
1.3.2

**Please tell us about your environment:**
* **Operating System:**
Replicated on various, with both recent Node and recent Chrome

**Current behavior:**
When we try to navigate to a route containing %0A or %0D, the routing system throw an exception. i.e.:
`/servlet/%0ARefresh:0;URL=javascript:prompt(1)%0A1`
`/servlet/%0DRefresh:0;URL=javascript:prompt(1)%0D1`

```
{
stack: "TypeError: Cannot read properties of null (reading '1')\n" +
' at findHandler (http://localhost:64909/____wallaby-bundle.js?1736489116181&wallabyFileId=bundle:46061:36)\n' +
' at RouteRecognizer.recognize (http://localhost:64909/____wallaby-bundle.js?1736489116181&wallabyFileId=bundle:45943:14)\n' +
' at Router._createNavigationInstruction (http://localhost:64909/____wallaby-bundle.js?1736489116181&wallabyFileId=bundle:23903:61)\n' +
' at AppRouter.loadUrl (http://localhost:64909/____wallaby-bundle.js?1736489116181&wallabyFileId=bundle:25023:14)\n' +
' at BrowserHistory._loadUrl (http://localhost:64909/____wallaby-bundle.js?1736489116181&wallabyFileId=bundle:9880:26)\n' +
' at BrowserHistory.activate (http://localhost:64909/____wallaby-bundle.js?1736489116181&wallabyFileId=bundle:9774:25)\n' +
' at AppRouter.activate (http://localhost:64909/____wallaby-bundle.js?1736489116181&wallabyFileId=bundle:25094:22)\n' +
' at http://localhost:64909/____wallaby-bundle.js?1736489116181&wallabyFileId=bundle:25065:31',
message: "Cannot read properties of null (reading '1')"
}
```

**Expected/desired behavior:**
Shouldn't throw an exception. If we change the %0A or the %0D to any other character, things work fine.

As a guess, I believe this may be something to do with how the route recogniser operates using regular expressions, and regular expressions behave differently when newline characters or carriage returns are inside the source text (as the source text becomes multi-line text).

Contributor guide

Open the contributing guide

Research direction

Start by locating findHandler and RouteRecognizer.recognize, the stack-trace entry points implicated by the failing routes. Reproduce both encoded-newline and encoded-carriage-return URLs, then verify that navigation no longer throws an exception and that ordinary routes still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.