All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.web.rules.Web.S4645.html Maven / Gradle / Ivy

The newest version!

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

<script type="text/template">
  <div>
    Hello!
  </div>
  <script type="text/javascript">  <!-- Noncompliant -->
    alert("Hi!");
  </script>
</script>

Compliant solution

<script type="text/javascript">
  alert("Hi!");
</script>

<script type="text/template">
  <div>
    Hello!
  </div>
</script>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy