Remove inject.js server-side injection for dapps (#8539)

* 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
This commit is contained in:
Axel Chalon 2018-05-11 12:09:42 +02:00 committed by Amaury Martiny
parent 25dc1c2155
commit 1fa95ac236
2 changed files with 2 additions and 43 deletions

View File

@ -17,9 +17,8 @@
use std::io; use std::io;
use std::time::{Duration, SystemTime}; use std::time::{Duration, SystemTime};
use hyper::{self, header, StatusCode}; use hyper::{self, header, StatusCode};
use hyper::mime::{self, Mime}; use hyper::mime::{Mime};
use apps;
use handlers::{Reader, ContentHandler, add_security_headers}; use handlers::{Reader, ContentHandler, add_security_headers};
use {Embeddable}; use {Embeddable};
@ -98,18 +97,7 @@ impl<T: DappFile> PageHandler<T> {
add_security_headers(&mut headers, self.safe_to_embed_on, self.allow_js_eval); 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 (reader, body) = Reader::pair(file.into_reader(), Vec::new());
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);
res.set_body(body); res.set_body(body);
(Some(reader), res) (Some(reader), res)
} }

View File

@ -60,32 +60,3 @@ fn should_serve_home() {
response.assert_header("Content-Type", "text/html"); response.assert_header("Content-Type", "text/html");
assert_security_headers(&response.headers); 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);
}