Ok - this is the dumbest glitch I've seen after a while:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <script type='text/javascript'> var data = "</script>"; </script> </head> <body> This should break! </body> </html>
This causes syntax errors because the JavaScript parser actually reads the contents of the string. So silly!
How can I put </script>in my code. Is there any way?
</script>
Is there a good reason for this behavior?
In X (HT) ML (when actually considered as such ), scripts must be escaped as CDATA for this very reason. http://www.w3.org/TR/xhtml1/diffs.html#h-4.8
XHTML script #PCDATA. < & , , < &, XML- < & , script CDATA .<script type="text/javascript"> <![CDATA[ ... unescaped script content ... ]]> </script>
XHTML script #PCDATA. < & , , < &, XML- < & , script CDATA .
<
&
<
&
<script type="text/javascript"> <![CDATA[ ... unescaped script content ... ]]> </script>
XHTML text/html -, , "" , '</scr' + 'ipt>'.
'</scr' + 'ipt>'
- , . HTML , </script>, . , :
// escape the / character, changing the format of the "closing" tag var data = "<\/script>"; // break up the string var data = "</"+"script>";
, HTML \ , , , , <\/script> . , - , ( ).
\
<\/script>
:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <script type='text/javascript'> <!-- var data = "</script>"; --> </script> </head> <body> This should break! </body> </html>
, HTML javascript, <!-- --> , .
<!--
-->
HTML4, script content
ETAGO ( "</" ), ([a-zA-Z])
, JavaScript , ; JavaScript var data = ", , , script.
var data = "
JavaScript - Andy E:
var data = "<\/script>";
, HTML </, script , \/ / JavaScript, . , JavaScript .
</
\/
/
Source: https://habr.com/ru/post/1742408/More articles:Php сеансы обеспечивают безопасный вход в систему - securityphp force download xml - xmlHow to use Ruby metaprogramming to reorganize this common code? - ruby | fooobar.comКак скачать файл с определенного URL-адреса? - objective-cJQuery: How to use jQuery delay using my own function? - javascriptBuilt in raytracing? - mathHow to visualize and detect line of sight? - mathUsing part of a class in multiple projects - c #How to save django object using dictionary? - djangohttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1742413/using-generics-to-typecast-object-type-to-generic-type&usg=ALkJrhjeCOsnjM-4skNZNpZEUoIt34h_RQAll Articles