`Authority::from_static` does not perform adequate validation
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 52/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- rust
- Bereich
- backend-api-design
Rechercherichtung
Start by reading Authority::from_static and the validation path used by parsing, then compare how both handle the provided https://127.0.0.1 example. The issue identifies no file or test, so locate the relevant URI authority tests and check what behavior they cover. Done means from_static rejects the invalid authority consistently with parsing, with regression coverage.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Version
http 1.3.1 (latest)
Platform
Linux 7.0.0-31
Summary
I'm not sure if this is a documentation issue or a behavioral issue (probably be the latter), but Authority::from_static does not perform proper validation of the provided authority string; it only checks whether each individual byte is valid.
Consider the following code (playground):
use http::uri::Authority;
fn main() {
// panics
// dbg!("https://127.0.0.1".parse::<Authority>().unwrap());
// produces "valid" authority
dbg!(Authority::from_static("https://127.0.0.1"));
}
This code was introduced in a seemingly faulty attempt (here) to make from_static const.
I doubt this is intentional, but if it is, the method should be called from_static_danger_only_validate_bytes or so, and the docs should provide more warning.
Code Sample
Expected Behavior
Both methods should fail, not just parse
Actual Behavior
from_static does not perform sufficient validation.
Additional Context
No response
- Vorherrschende Sprache
- Rust
- Sterne
- 1.4k
- Forks
- 385
- Ø Merge
- 1 T. 5 Std.
- Gemergte PRs (30 T.)
- 2
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus hyperium/http
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 62/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 58/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 62/100
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
nannou-org/egui_graph#92 ·
Maintainer antworten meist innerhalb von 1 Tag
-
documentation good first issue
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 72/100
sujithputta02/Esapay#13 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
tursodatabase/turso#10002 ·
Maintainer antworten meist innerhalb von 1 Tag
-
needs triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
topgrade-rs/topgrade#2419 ·
Maintainer antworten meist innerhalb von 1 Tag
-
review-bot
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
midagedev/bloomery#318 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag