Skip to content

Commit

Permalink
Properly escape & in injected live-reload script tag (#825)
Browse files Browse the repository at this point in the history
"[…] `&` 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
  • Loading branch information
homeworkprod authored and Keats committed Feb 3, 2020
1 parent b3bc8a8 commit 587d739
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/site/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
);
Expand Down
2 changes: 1 addition & 1 deletion components/site/tests/site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down

0 comments on commit 587d739

Please sign in to comment.