aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2014-09-16 14:31:45 +0100
committerSimon Sapin <simon.sapin@exyr.org>2014-09-16 14:41:45 +0100
commit11135d75cb4dc8352df1743b9ceadc8e6ec1876c (patch)
tree9cf891fd8afb4f405236d6601619663f7870a9c2 /src
parent7a5f15f13723a6c510ed05ad7875eb10b290dea2 (diff)
downloadservo-11135d75cb4dc8352df1743b9ceadc8e6ec1876c.tar.gz
servo-11135d75cb4dc8352df1743b9ceadc8e6ec1876c.zip
Try to parse command line argument as file names
… 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.
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/lib.rs b/src/lib.rs
index bb01ad7c739..a00d935ade3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -57,8 +57,6 @@ use std::os;
use std::task::TaskBuilder;
#[cfg(not(test), target_os="android")]
use std::string;
-#[cfg(not(test))]
-use url::{Url, UrlParser};
#[cfg(not(test), target_os="android")]
#[no_mangle]
@@ -125,12 +123,15 @@ pub fn run(opts: opts::Opts) {
font_cache_task,
time_profiler_chan_clone);
- let base_url = Url::from_directory_path(&os::getcwd()).unwrap();
- let mut url_parser = UrlParser::new();
- let url_parser = url_parser.base_url(&base_url);
// Send the URL command to the constellation.
- for url in opts.urls.iter() {
- let url = url_parser.parse(url.as_slice()).ok().expect("URL parsing failed");
+ let cwd = os::getcwd();
+ for &url in opts.urls.iter() {
+ let url = match url::Url::parse(url.as_slice()) {
+ Ok(url) => url,
+ Err(url::RelativeUrlWithoutBase)
+ => url::Url::from_file_path(&cwd.join(url)).unwrap(),
+ Err(_) => fail!("URL parsing failed"),
+ };
let ConstellationChan(ref chan) = constellation_chan;
chan.send(InitLoadUrlMsg(url));