-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore set_scheme when input contains trailing/leading C0 controls #816
base: main
Are you sure you want to change the base?
Conversation
d330e70
to
cbc1b50
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #816 +/- ##
==========================================
- Coverage 82.74% 82.72% -0.02%
==========================================
Files 20 20
Lines 3303 3305 +2
==========================================
+ Hits 2733 2734 +1
- Misses 570 571 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
806225f
to
f6aaf80
Compare
f6aaf80
to
9c16caa
Compare
@@ -2313,6 +2313,12 @@ impl Url { | |||
/// ``` | |||
#[allow(clippy::result_unit_err, clippy::suspicious_operation_groupings)] | |||
pub fn set_scheme(&mut self, scheme: &str) -> Result<(), ()> { | |||
// If the given scheme contains leading or trailing C0 controls, | |||
// we'll ignore the set_scheme operation. | |||
if scheme.trim_matches(|ch| ch <= ' ').len() != scheme.len() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two problems here:
- I think we should early exit if the scheme
contains
a Non-tab/newline C0 controls - not just leading or trailing - This would still match tabs and newlines.
Please add a test for one of these chars in the middle of the scheme.
Also a test that setting it to https\n
still works.
☔ The latest upstream changes (presumably 1158370) made this pull request unmergeable. Please resolve the merge conflicts. |
When we use the
parser::Input::new
, it will initialize the input iterator with trimming both whitespaces and C0 controls. However, for scheme, we should only trim whitespaces. Thus, with moving from::new
to::trim_tab_and_newlines
could fix the issue.This PR will fix #815.