Improper location decoding
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 32/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- typescript
Direzione di ricerca
Non sono indicati file o test. Inizia tracciando il route matching e ogni chiamata di location a decodeURI, quindi riproduci gli esempi encoded-slash e percent dell’issue. Il lavoro è completato quando i parametri delle route preservano i delimitatori codificati e la decodifica successiva rimane non ambigua senza errori URI; aggiungi una copertura di regressione mirata per questi casi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
As of wouter 3.x, the library now calls decodeURI on locations during route matching, meaning route parameters have had this called on them as well. I'm not quite sure why this was added, as it doesn't match how routing would work in a typical HTTP server. That is, if I hit:
GET /path/escaped%2Fslashes
the intent is that this %2F is not treated like a slash, so if we were serving e.g. directories of files, this would look for a file named escaped%2Fslashes in the directory path, not a directory named escaped containing a file named slashes.
This presents a problem that is not solvable for clients of this library if any of their route components can contain a certain collection of characters. You can end up with a parameter value that can no longer be decoded unambiguously.
For instance, if you allow parameters that contain a % and #, you must use encodeURIComponent on this parameter or the resulting location will not work properly, but decodeURI will partially decode this string and you can no longer determine what the original string was without parsing (and effectively doing the routing) yourself:
const url = '/' + encodeURIComponent(`foo/bar#baz%`) // 'foo%2Fbar%23baz%25'
const afterWouter = decodeURI(url) // '/foo/bar%23baz%'
const laterDecode = decodeURIComponent(afterWouter) // throws "URIError: URI malformed"
Since the original string could also contain e.g. %25 at the end, the string at afterWouter is now ambiguous as well: we cannot tell whether the original string contained % or %25 unless we go back and look at the location value, and decoding multiple times may actually "work" without throwing an error but give you a value that is not the same as the original.
Calling decodeURI on the entire URL string multiple times makes issues like this impossible to fix, and wouter at this point seems to do it quite often.
- Lingua principale
- TypeScript
- Stelle
- 7.9k
- Fork
- 193
- Merge medio
- 9m
- PR unite (30g)
- 1
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di molefrog/wouter
-
Wouter double-decodes search params in `useSearchParams`, which can lead to �Forse già presa @priyas1672 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Links using ~ do not respect `base`Forse già presa @molefrog l’ha presa 24 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
Tutte le issue di molefrog/wouter
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
awslabs/visual-asset-management-system#937 ·
I maintainer di solito rispondono entro 1 giorno
-
t0ggles
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
nolimits4web/swiper#8255 · 1 commento ·
I maintainer di solito rispondono entro 15 giorni
-
render: --variables-file (and --variables <path>) fails with "io.readFile is not a function" since 0.8.212Forse già presa @miguel-heygen l’ha presa oggi. Apertabug triage/needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
heygen-com/hyperframes#6830 ·
I maintainer di solito rispondono entro 1 giorno
-
bug launch local use
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
account: profile bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 5 giorni