Merge branch 'master' into streamlined-ui

This commit is contained in:
Tomasz Drwięga
2016-07-12 12:06:01 +02:00
65 changed files with 879 additions and 601 deletions

View File

@@ -20,7 +20,7 @@ ethcore-util = { path = "../util" }
ethcore-rpc = { path = "../rpc" }
parity-dapps-signer = { git = "https://github.com/ethcore/parity-ui.git", version = "0.2.0" }
clippy = { version = "0.0.78", optional = true}
clippy = { version = "0.0.79", optional = true}
[features]
dev = ["clippy"]

View File

@@ -25,11 +25,11 @@ use std::str::FromStr;
use jsonrpc_core::IoHandler;
use util::H256;
fn origin_is_allowed(self_origin: &str, header: Option<&Vec<u8>>) -> bool {
fn origin_is_allowed(self_origin: &str, header: Option<&[u8]>) -> bool {
match header {
None => false,
Some(h) => {
let v = String::from_utf8(h.clone()).ok();
let v = String::from_utf8(h.to_owned()).ok();
match v {
Some(ref origin) if origin.starts_with("chrome-extension://") => true,
Some(ref origin) if origin.starts_with(self_origin) => true,
@@ -84,8 +84,8 @@ pub struct Session {
impl ws::Handler for Session {
fn on_request(&mut self, req: &ws::Request) -> ws::Result<(ws::Response)> {
let origin = req.header("origin").or_else(|| req.header("Origin"));
let host = req.header("host").or_else(|| req.header("Host"));
let origin = req.header("origin").or_else(|| req.header("Origin")).map(|x| &x[..]);
let host = req.header("host").or_else(|| req.header("Host")).map(|x| &x[..]);
// Check request origin and host header.
if !origin_is_allowed(&self.self_origin, origin) && !(origin.is_none() && origin_is_allowed(&self.self_origin, host)) {