Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Remove inject.js server-side injection for dapps (#8539)
Browse files Browse the repository at this point in the history
* Remove inject.js server-side injection for dapps

* Remove dapps test `should_inject_js`

Parity doesn't inject a <script> tag inside the responses anymore
  • Loading branch information
axelchalon authored and amaury1093 committed May 11, 2018
1 parent 25dc1c2 commit 1fa95ac
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
16 changes: 2 additions & 14 deletions dapps/src/page/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
use std::io;
use std::time::{Duration, SystemTime};
use hyper::{self, header, StatusCode};
use hyper::mime::{self, Mime};
use hyper::mime::{Mime};

use apps;
use handlers::{Reader, ContentHandler, add_security_headers};
use {Embeddable};

Expand Down Expand Up @@ -98,18 +97,7 @@ impl<T: DappFile> PageHandler<T> {
add_security_headers(&mut headers, self.safe_to_embed_on, self.allow_js_eval);
}

let initial_content = if file.content_type().to_owned() == mime::TEXT_HTML {
let content = &format!(
r#"<script src="/{}/inject.js"></script>"#,
apps::UTILS_PATH,
);

content.as_bytes().to_vec()
} else {
Vec::new()
};

let (reader, body) = Reader::pair(file.into_reader(), initial_content);
let (reader, body) = Reader::pair(file.into_reader(), Vec::new());
res.set_body(body);
(Some(reader), res)
}
Expand Down
29 changes: 0 additions & 29 deletions dapps/src/tests/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,32 +60,3 @@ fn should_serve_home() {
response.assert_header("Content-Type", "text/html");
assert_security_headers(&response.headers);
}


#[test]
fn should_inject_js() {
// given
let server = serve_ui();

// when
let response = request(server,
"\
GET / HTTP/1.1\r\n\
Host: 127.0.0.1:8080\r\n\
Connection: close\r\n\
\r\n\
{}
"
);

// then
response.assert_status("HTTP/1.1 200 OK");
response.assert_header("Content-Type", "text/html");
assert_eq!(
response.body.contains(r#"/inject.js"></script>"#),
true,
"Expected inject script tag in: {}",
response.body
);
assert_security_headers(&response.headers);
}

0 comments on commit 1fa95ac

Please sign in to comment.