Vue-router decodeURI twice cause URL contains encoded % an URIError: URI malformed
See original GitHub issueVersion
3.0.3
Reproduction link
Sorry, It is hard to supply a minimal reproduction
Steps to reproduce
Visit http://a.b.c/#/test?d=%25
Vue-router will throw a warning URIError: URI malformed
, and abandon all the query params.
What is expected?
DecodeURI once is enough.
What is actually happening?
DecodeURI twice.
ref: https://github.com/vuejs/vue-router/blob/627027fd4351c1a6fa4926765c805165a56d7818/src/history/hash.js#L100-L106 https://github.com/vuejs/vue-router/blob/627027fd4351c1a6fa4926765c805165a56d7818/src/util/query.js#L37-L63
The getHash
method already decoded href, but parseQuery
decode it again. So caused URIError: URI malformed
.
Maybe decoding in getHash
is not necessary.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
URIError: malformed URI sequence - MDN Web Docs - Mozilla
URIError : malformed URI sequence. The JavaScript exception "malformed URI sequence" occurs when URI encoding or decoding wasn't successful.
Read more >issue when % character is in url - Stack Overflow
It looks to me like you are encoding characters in your URL twice and then trying to decode them. %2525%2525PAGE%2525%2525 decodes to %25%25PAGE ......
Read more >Vue router decodes URI twice, creates errors when % are in ...
I have worked around this by overriding the parseQuery function in my router to a copy of the default but without any decodes...
Read more >How to Fix Uncaught URIError: URI malformed Errors in JS
Here we are trying to encode an invalid Unicode character. The reason this is invalid for encoding is that the Unicode code range...
Read more >Uri Malformed, Cannot Be Parsed - While Connecting To ...
between URI and URL which service using port 80 command org.apache.http. ... encoded contains invalid character Edge URIError: malformed URI ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Check #2725
BTW
%
is not a valid character in a url (per spec). You have to use the escaped version%25
Has released in 3.0.4 https://github.com/vuejs/vue-router/commit/81cfe71296caa5cde21f780ece1910b172b8e5f7 .