Re: [xml] DOM parser and HTML entities inside the <script> tag

Raymond Irving schrieb am 17.07.2012 um 13:51 (-0500):

When the following code is passed through the parser:

<script type="text/javascript">
   var d="&quot;Hello world;&quot;";

it will be converted to:

<script type="text/javascript">
   var d=""Hello world"";

The XML parser doesn't know that the <script> element is special (as you
correctly point out in the part I'm quoting below).

MiLu Dago: ~ > xmllint
<?xml version="1.0"?>
<script type="text/javascript">
   var d=""Hello world;"";

Use the HTML parser instead:

MiLu Dago: ~ > xmllint --html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "";>
<html><head><script type="text/javascript">
   var d="&quot;Hello world;&quot;";


According to the entities should not be replaced replaces inside
CDATA sections, scripts or styles

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]