Skip to content

Try to parse command line argument as file names - #3365

Merged
SimonSapin merged 2 commits into
servo:masterfrom
SimonSapin:command-line-argument-filenames
Sep 16, 2014
Merged

SimonSapin merged 2 commits into
servo:masterfrom
SimonSapin:command-line-argument-filenames

Conversation

@SimonSapin

Copy link
Copy Markdown
Member

… 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 servo#3340.
@hoppipolla-critic-bot

Copy link
Copy Markdown

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

jdm commented Sep 16, 2014

Copy link
Copy Markdown
Member
---- ../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

cgaebel commented Sep 16, 2014

Copy link
Copy Markdown

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
Copy Markdown
Member Author

@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

cgaebel commented Sep 16, 2014

Copy link
Copy Markdown

Ok.

@SimonSapin

Copy link
Copy Markdown
Member Author

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
@SimonSapin
SimonSapin deleted the command-line-argument-filenames branch September 16, 2014 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stackoverflow post fails to load

4 participants