Properly escape & in injected live-reload script tag (#825)

"[…] `&` normally indicates the start of a character entity reference or
numeric character reference; writing it as `&` […] allows `&` to be
included in the content of an element or in the value of an attribute."

From: https://en.wikipedia.org/wiki/HTML#Character_and_entity_references
This commit is contained in:
Jochen Kupperschmidt 2019-10-25 00:53:18 +02:00 committed by Vincent Prouillet
parent b3bc8a8896
commit 587d7396b3
2 changed files with 2 additions and 2 deletions

View file

@ -633,7 +633,7 @@ impl Site {
return html.replace(
"</body>",
&format!(
r#"<script src="/livereload.js?port={}&mindelay=10"></script></body>"#,
r#"<script src="/livereload.js?port={}&amp;mindelay=10"></script></body>"#,
port
),
);

View file

@ -161,7 +161,7 @@ fn can_build_site_without_live_reload() {
assert!(file_exists!(public, "nested_sass/scss.css"));
// no live reload code
assert_eq!(file_contains!(public, "index.html", "/livereload.js?port=1112&mindelay=10"), false);
assert_eq!(file_contains!(public, "index.html", "/livereload.js?port=1112&amp;mindelay=10"), false);
// Both pages and sections are in the sitemap
assert!(file_contains!(