diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-08-01 09:53:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-01 09:53:11 -0400 |
commit | 890d40dd4fc5d30c9b5fb5cc06bfabb0650eb16c (patch) | |
tree | 6995a256d7497b90160f0cf0f78ffb72c8cd62b8 | |
parent | 3e09d7270a55800ef75207964ae2c41160493ec8 (diff) | |
parent | fb8d8b33ac12e091a185036eae8d11d295795a20 (diff) | |
download | servo-890d40dd4fc5d30c9b5fb5cc06bfabb0650eb16c.tar.gz servo-890d40dd4fc5d30c9b5fb5cc06bfabb0650eb16c.zip |
Auto merge of #21308 - paulrouget:jsonerror, r=jdm
Android: Fix JSON error when no arguments are passed
Probably fix #21298
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21308)
<!-- Reviewable:end -->
-rw-r--r-- | ports/libsimpleservo/src/api.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/ports/libsimpleservo/src/api.rs b/ports/libsimpleservo/src/api.rs index a271dda59e4..440ae2a8aa5 100644 --- a/ports/libsimpleservo/src/api.rs +++ b/ports/libsimpleservo/src/api.rs @@ -95,12 +95,14 @@ pub fn init( ) -> Result<(), &'static str> { resources::set(Box::new(ResourceReader(readfile))); - let mut args: Vec<String> = serde_json::from_str(&argsline).map_err(|_| { - "Invalid arguments. Servo arguments must be formatted as a JSON array" - })?; - // opts::from_cmdline_args expects the first argument to be the binary name. - args.insert(0, "servo".to_string()); - opts::from_cmdline_args(&args); + if !argsline.is_empty() { + let mut args: Vec<String> = serde_json::from_str(&argsline).map_err(|_| { + "Invalid arguments. Servo arguments must be formatted as a JSON array" + })?; + // opts::from_cmdline_args expects the first argument to be the binary name. + args.insert(0, "servo".to_string()); + opts::from_cmdline_args(&args); + } let embedder_url = embedder_url.as_ref().and_then(|s| { ServoUrl::parse(s).ok() |