Skip to content

Commit

Permalink
Double quote HTML attribute values.
Browse files Browse the repository at this point in the history
  • Loading branch information
xwmx committed Nov 7, 2023
1 parent 8446c0a commit 9625472
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 10 deletions.
4 changes: 2 additions & 2 deletions nb
Original file line number Diff line number Diff line change
Expand Up @@ -10674,7 +10674,7 @@ _render() {
if [[ -n "${_custom_javascript_url:-}" ]]
then
_custom_javascript_url_element="\
<script src='${_custom_javascript_url:-}'></script>"
<script src=\"${_custom_javascript_url:-}\"></script>"
fi

if [[ -n "${_custom_css:-}" ]]
Expand All @@ -10686,7 +10686,7 @@ _render() {
if [[ -n "${_custom_css_url:-}" ]]
then
_custom_css_url_element="\
<link rel='stylesheet' href='${_custom_css_url:-}'/>"
<link rel=\"stylesheet\" href=\"${_custom_css_url:-}\"/>"
fi

cat <<HEREDOC
Expand Down
58 changes: 50 additions & 8 deletions test/browse.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ load test_helper

[[ "${status}" -eq 0 ]]

[[ ! "${output}" =~ \<link\ rel=\'stylesheet\' ]]
[[ ! "${output}" =~ \<link\ rel=\"stylesheet\" ]]
[[ ! "${output}" =~ \<script\ src= ]]
}

@test "'browse' includes custom css and javascript tags when assigned." {
@test "'browse' includes custom css and javascript tags with NB_CUSTOM_CSS and NB_CUSTOM_JS assigned." {
{
"${_NB}" init

Expand All @@ -44,12 +44,26 @@ load test_helper

[[ "${status}" -eq 0 ]]

[[ ! "${output}" =~ \<link\ rel=\'stylesheet\' ]]
[[ ! "${output}" =~ \<link\ rel=\"stylesheet\" ]]
[[ ! "${output}" =~ \<script\ src= ]]
[[ "${output}" =~ \
\<style\>${_NEWLINE}.example\ {\ color:\ blue\;\ }${_NEWLINE}\</style\> ]]
[[ "${output}" =~ \
\<script\>${_NEWLINE}function\ example\(\)\ {\ console.log\(\"Example.\"\)\;\ }${_NEWLINE}\</script\> ]]
}

@test "'browse' includes custom css and javascript tags with NB_CUSTOM_CSS and NB_CUSTOM_JAVASCRIPT assigned." {
{
"${_NB}" init

sleep 1

declare _custom_css=".example { color: blue; }"
declare _custom_js="function example() { console.log(\"Example.\"); }"

declare _custom_css_url="//--original/home/example.css"
declare _custom_js_url="//--original/home/example.js"
}

NB_CUSTOM_CSS="${_custom_css:-}" \
NB_CUSTOM_JAVASCRIPT="${_custom_js:-}" \
Expand All @@ -60,12 +74,26 @@ load test_helper

[[ "${status}" -eq 0 ]]

[[ ! "${output}" =~ \<link\ rel=\'stylesheet\' ]]
[[ ! "${output}" =~ \<link\ rel=\"stylesheet\" ]]
[[ ! "${output}" =~ \<script\ src= ]]
[[ "${output}" =~ \
\<style\>${_NEWLINE}.example\ {\ color:\ blue\;\ }${_NEWLINE}\</style\> ]]
[[ "${output}" =~ \
\<script\>${_NEWLINE}function\ example\(\)\ {\ console.log\(\"Example.\"\)\;\ }${_NEWLINE}\</script\> ]]
}

@test "'browse' includes custom css and javascript tags with NB_CUSTOM_CSS_URL and NB_CUSTOM_JS_URL assigned." {
{
"${_NB}" init

sleep 1

declare _custom_css=".example { color: blue; }"
declare _custom_js="function example() { console.log(\"Example.\"); }"

declare _custom_css_url="//--original/home/example.css"
declare _custom_js_url="//--original/home/example.js"
}

NB_CUSTOM_CSS_URL="${_custom_css_url:-}" \
NB_CUSTOM_JS_URL="${_custom_js_url:-}" \
Expand All @@ -77,13 +105,27 @@ load test_helper
[[ "${status}" -eq 0 ]]

[[ "${output}" =~ \
\<link\ rel=\'stylesheet\'\ href=\'//--original/home/example.css\'/\> ]]
\<link\ rel=\"stylesheet\"\ href=\"//--original/home/example.css\"/\> ]]
[[ "${output}" =~ \
\<script\ src=\'//--original/home/example.js\'\>\</script\> ]]
\<script\ src=\"//--original/home/example.js\"\>\</script\> ]]
[[ ! "${output}" =~ \
\<style\>${_NEWLINE}.example\ {\ color:\ blue\;\ }${_NEWLINE}\</style\> ]]
[[ ! "${output}" =~ \
\<script\>${_NEWLINE}function\ example\(\)\ {\ console.log\(\"Example.\"\)\;\ }${_NEWLINE}\</script\> ]]
}

@test "'browse' includes custom css and javascript tags with NB_CUSTOM_CSS_URL and NB_CUSTOM_JAVASCRIPT_URL assigned." {
{
"${_NB}" init

sleep 1

declare _custom_css=".example { color: blue; }"
declare _custom_js="function example() { console.log(\"Example.\"); }"

declare _custom_css_url="//--original/home/example.css"
declare _custom_js_url="//--original/home/example.js"
}

NB_CUSTOM_CSS_URL="${_custom_css_url:-}" \
NB_CUSTOM_JAVASCRIPT_URL="${_custom_js_url:-}" \
Expand All @@ -95,9 +137,9 @@ load test_helper
[[ "${status}" -eq 0 ]]

[[ "${output}" =~ \
\<link\ rel=\'stylesheet\'\ href=\'//--original/home/example.css\'/\> ]]
\<link\ rel=\"stylesheet\"\ href=\"//--original/home/example.css\"/\> ]]
[[ "${output}" =~ \
\<script\ src=\'//--original/home/example.js\'\>\</script\> ]]
\<script\ src=\"//--original/home/example.js\"\>\</script\> ]]
[[ ! "${output}" =~ \
\<style\>${_NEWLINE}.example\ {\ color:\ blue\;\ }${_NEWLINE}\</style\> ]]
[[ ! "${output}" =~ \
Expand Down

0 comments on commit 9625472

Please sign in to comment.