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

Try to parse command line argument as file names #3365

Merged
merged 2 commits into from Sep 16, 2014

Conversation

@SimonSapin
Copy link
Member

SimonSapin commented Sep 16, 2014

… when parsing as an absolute URL (without a base) fails.

Previously, arguments were parsed as URLs with the current working directory converted to an URL and used as the base URL. This mostly worked for relative filenames, except that ? and # had a special meaning and needed to be percent-encoded.

Fix #3340.

r? @metajack

… when parsing as an absolute URL (without a base) fails.

Previously, arguments were parsed as URLs with the current working directory
converted to an URL and used as the base URL. This mostly worked for
relative filenames, except that `?` and `#` had a special meaning
and needed to be percent-encoded.

Fix #3340.
@hoppipolla-critic-bot
Copy link

hoppipolla-critic-bot commented Sep 16, 2014

Critic review: https://critic.hoppipolla.co.uk/r/2607

This is an external review system which you may optionally use for the code review of your pull request.

In order to help critic track your changes, please do not make in-place history rewrites (e.g. via git rebase -i or git commit --amend) when updating this pull request.

@jdm
Copy link
Member

jdm commented Sep 16, 2014

---- ../html/acid2.html#top != acid2_ref.html stdout ----
task '../html/acid2.html#top != acid2_ref.html' failed at 'assertion failed: retval == ExitStatus(0)', tests/reftest.rs:233

Whoops.

The previous commit made #top be considered part of the file name in
../html/acid2.html#top
@cgaebel
Copy link
Contributor

cgaebel commented Sep 16, 2014

I have a one-line patch to rust-url that accomplishes the same thing. It may or may not be worse, but I'll post it here for you guys to decide.

diff --git a/src/parser.rs b/src/parser.rs
index 3958715..9653353 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -533,7 +533,7 @@ fn parse_path<'a>(base_path: &[String], input: &'a str, context: Context,
                     end = i;
                     break
                 },
-                '?' | '#' if context == UrlParserContext => {
+                '?' | '#' if scheme_type != FileLikeRelativeScheme && context == UrlParserContext => {
                     end = i;
                     break
                 },
@SimonSapin
Copy link
Member Author

SimonSapin commented Sep 16, 2014

@cgaebel, no, ? and # should start the query string or fragment identifier when parsing an URL, including in the file: scheme. The question is whether command-line arguments are always (possibly relative) URLs or can be filenames in OS-specific notation. This PR does the latter.

@cgaebel
Copy link
Contributor

cgaebel commented Sep 16, 2014

Ok.

@SimonSapin
Copy link
Member Author

SimonSapin commented Sep 16, 2014

But thanks for the help anyway! :)

SimonSapin added a commit that referenced this pull request Sep 16, 2014
Try to parse command line argument as file names
@SimonSapin SimonSapin merged commit 14f7d2d into servo:master Sep 16, 2014
1 check passed
1 check passed
continuous-integration/travis-ci The Travis CI build passed
Details
@SimonSapin SimonSapin deleted the SimonSapin:command-line-argument-filenames branch Sep 16, 2014
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.

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