< and > not correctly parsed

Bug #517064 reported by jazzynico on 2010-02-04
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Scour
Critical
Unassigned

Bug Description

Hi,

< and > are sometimes used in Inkscape's tutorials (tracing, tips...).
But when I scour that text:
<flowDiv xml:space="preserve">One of the features in Inkscape is a tool for tracing a bitmap image
into a &lt;path&gt; element for your SVG drawing. These short notes
should help you become acquainted with how it works.
</flowDiv>

&lt; is replaced with < and I get:
<flowDiv xml:space="preserve">One of the features in Inkscape is a tool for tracing a bitmap image
into a <path&gt; element for your SVG drawing. These short notes
should help you become acquainted with how it works.
</flowDiv>

And Inkscape returns an error if I try to open it.

Commenting the following lines:
 # encode > as &gt; (TODO: is this necessary?)
 if str.find('>') != -1:
  newstr = str.replace('>', '&gt;')

in def makeWellFormed(str) fixes this issue.

But can &lt;MyText> considered valid?

Regards.

codedread (codedread) wrote :

Thanks for catching this, Nico!

I have fixed this in my local copy. Will checkin tonight, but for now you can replace the makeWellFormed() function with this:

def makeWellFormed(str):
 newstr = ''
 xml_ents = { '<':'&lt;', '>':'&gt;', '&':'&amp;', "'":'&apos;', '"':'&quot;'}
 for c in str:
  if c in xml_ents:
   newstr += xml_ents[c]
  else:
   newstr += c

 return newstr

Sorry about the trouble.

Changed in scour:
status: New → Confirmed
importance: Undecided → Critical
codedread (codedread) wrote :

Ok, pushed in r158.

Changed in scour:
status: Confirmed → Fix Committed
codedread (codedread) on 2010-02-05
Changed in scour:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers