rspec/rules/S4645/html/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

53 lines
1.3 KiB
Plaintext

== Why is this an issue?
When parsing a script node, the browser treats its contents as plain text, and immediately finishes parsing when it finds the first closing ``++</script>++`` character sequence.
As a consequence, nested script nodes are not possible, because all opening ``++<script>++`` tags found along the way are ignored.
Web browsers doesn't support nested ``++<script>...</script>++`` elements. But there is no error in such case and browsers just close the first encountered ``++<script>++`` tag as soon as a closing ``++</script>++`` tag is found along the way. So there is a big chance to display something totally unexpected to the end-users.
=== Noncompliant code example
[source,html]
----
<script type="text/template">
<div>
Hello!
</div>
<script type="text/javascript"> <!-- Noncompliant -->
alert("Hi!");
</script>
</script>
----
=== Compliant solution
[source,html]
----
<script type="text/javascript">
alert("Hi!");
</script>
<script type="text/template">
<div>
Hello!
</div>
</script>
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
A </script> was found without a relating opening <script> tag. This may be caused by nested script tags.
endif::env-github,rspecator-view[]