Skip to content
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

Truncate the serialization in Url::take_after_path #223

Merged
merged 4 commits into from Sep 28, 2016

Conversation

@emilio
Copy link
Member

emilio commented Sep 1, 2016

Fixes #222

I did this under the assumption that extending with an empty segment is a no-op. If we want it to cause something like foo.com/bar//baz, then the bit in path_segments_mut needs to be removed.

r? @SimonSapin


This change is Reviewable

@untitaker
Copy link
Contributor

untitaker commented Sep 18, 2016

Empty path segments are used for the eventual trailing slash in paths.

@emilio emilio force-pushed the emilio:empty-path-push branch from bb52524 to 63df2a7 Sep 18, 2016
@emilio
Copy link
Member Author

emilio commented Sep 18, 2016

@untitaker: Fair enough, removed that bit.

@untitaker
Copy link
Contributor

untitaker commented Sep 18, 2016

Also the testcase I provided in #222 still appears to fail :)

Really apprechiate your work btw, I never got around to do this myself but
wanted to.

On Sun, Sep 18, 2016 at 12:47:10AM -0700, Emilio Cobos Álvarez wrote:

@untitaker: Fair enough, removed that bit.

You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#223 (comment)

emilio added 2 commits Sep 1, 2016
…ments in PathSegmentsMut::extend.

Fixes #222
@emilio emilio force-pushed the emilio:empty-path-push branch from 63df2a7 to 7225866 Sep 18, 2016
@emilio
Copy link
Member Author

emilio commented Sep 18, 2016

@untitaker: That's because that is_empty() bit, and because I'm stupid and forgot to push :)

@emilio emilio force-pushed the emilio:empty-path-push branch from 71bb612 to 7225866 Sep 18, 2016
@untitaker
Copy link
Contributor

untitaker commented Sep 18, 2016

Hmm the AppVeyor build fails!

@untitaker
Copy link
Contributor

untitaker commented Sep 18, 2016

(also it probably would make sense to add my testcase to this PR)

Copy link
Member

Hoverbear left a comment

LGTM just fix the Appveyor build. :))

@Phrohdoh
Copy link

Phrohdoh commented Sep 18, 2016

This also fixes #227.

@emilio If you don't mind would you also apply this:

diff --git a/tests/unit.rs b/tests/unit.rs
index 2617178..5d3494b 100644
--- a/tests/unit.rs
+++ b/tests/unit.rs
@@ -288,3 +288,14 @@ fn append_empty_segment_then_mutate() {
     url.assert_invariants();
     assert_eq!(url.to_string(), "http://localhost:6767/foo/bar?a=b");
 }
+
+#[test]
+/// https://github.com/servo/rust-url/issues/227
+fn extend_query_pairs_then_mutate() {
+    let mut url: Url = "http://localhost:6767/foo/bar".parse().unwrap();
+    url.query_pairs_mut().extend_pairs(vec![ ("auth", "my-token") ].into_iter());
+    assert_eq!(url.to_string(), "http://localhost:6767/foo/bar?auth=my-token");
+    url.path_segments_mut().unwrap().push("some_other_path");
+    assert_eq!(url.to_string(), "http://localhost:6767/foo/bar/some_other_path?auth=my-token");
+}

I do not know when assert_invariants should be used so I did not include it.

emilio added 2 commits Sep 18, 2016
Windows expects in `path_to_file_url_segments_windows` a Disk or a VerbatimDisk
as the first path component, which this test doesn't hold, and thus it panic.

I sincerely don't know how this could pass in the first time (did it?).
@emilio emilio force-pushed the emilio:empty-path-push branch from 781c9e1 to 4d4f1a3 Sep 18, 2016
@emilio
Copy link
Member Author

emilio commented Sep 18, 2016

@Hoverbear: The AppVeyor build fails at parsing the first URL in that test (/), because path_to_file_url_segments_windows expects a disk prefix or otherwise returns an error.

I "fixed" it by conditionally compiling that test. I'm pretty sure that failure has nothing to do with these changes (I doubt it passed CI in the first place?).

@emilio
Copy link
Member Author

emilio commented Sep 18, 2016

Yeah, indeed all the closed PRs since the addition of that test fail on AppVeyor.

@emilio emilio changed the title Truncate the serialization in Url::take_after_path, discard empty segments in PathSegmentsMut::extend. Truncate the serialization in Url::take_after_path Sep 18, 2016
@SimonSapin
Copy link
Member

SimonSapin commented Sep 28, 2016

@bors-servo r=hoverbear+simonsapin

@bors-servo
Copy link
Contributor

bors-servo commented Sep 28, 2016

📌 Commit 4d4f1a3 has been approved by hoverbear+simonsapin

@bors-servo
Copy link
Contributor

bors-servo commented Sep 28, 2016

Test exempted - status

@bors-servo bors-servo merged commit 4d4f1a3 into servo:master Sep 28, 2016
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
bors-servo added a commit that referenced this pull request Sep 28, 2016
Truncate the serialization in Url::take_after_path

Fixes #222

I did this under the assumption that extending with an empty segment is a no-op. If we want it to cause something like `foo.com/bar//baz`, then the bit in `path_segments_mut` needs to be removed.

r? @SimonSapin

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/223)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.