script tag should be CDATA?

Bug #168405 reported by singlecell
2
Affects Status Importance Assigned to Milestone
Inkscape
Incomplete
Low
Unassigned

Bug Description

Inkscape should treat script element as CDATA, as it currently treats it as
a text node and replaces " with " etc.

for example, if the following script is added to the SVG file (under the
<SVG> element):
  <script type="text/ecmascript" id="script2259">
  function setColour(evt)
  {
  var colour= evt.target.getAttribute("fill");
         }
  </script>

when it is later saved by inkscape it becomes:

  <script type="text/ecmascript" id="script2259">
  function setColour(evt)
  {
  var colour= evt.target.getAttribute("fill");
         }
  </script>

Inkscape also loses script attributes (at least from root svg) when saving
as Plain SVG.

Tags: saving
Revision history for this message
Jon A. Cruz (jon-joncruz) wrote :

Originator: NO

Technically CDATA is just escaping things inside of a text node. It is
just an optional sub-part, and multiple CDATA sections could go into a
single text node, yet still be functionally equivalent as far as the
programs using it go:

<script type="text/ecmascript" id="script2259">
function setColour(evt)
{
var colour= evt.target.getAttribute(<![CDATA["]]>fill<![CDATA["]]>);
}
</script>

or

<script type="text/ecmascript" id="script2259">
function setColour(evt)
{
var colour= evt.target.getAttribute(<![CDATA["]]>fill");
}
</script>

(and splitting that last sentence to a separate bug would help)

Revision history for this message
singlecell (singlecell) wrote :

Originator: YES

OK, the last line about loosing script attributes when saving as plain SVG
has already be raised as issue 1484781. Sorry, please ignore that bit.

Revision history for this message
Bryce Harrington (bryce) wrote :

What changes to the codebase are needed to address this issue?

Changed in inkscape:
status: New → Incomplete
Revision history for this message
singlecell (singlecell) wrote :

Could the script attribute be handled as a special case?

Perhaps any elements could automatically add "<![CDATA[" and "]]>" when it is saved:

<script type="text/ecmascript" id="script2259">...</script>

automatically saved as:

<script type="text/ecmascript" id="script2259">
<![CDATA[
...
]]>
</script>

(If nothing else, it will reduce the size of the saved file.)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.