diff --git a/package.sh b/package.sh
index 8a3fb6a..ec2fe7b 100755
--- a/package.sh
+++ b/package.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-SCOURVER="0.23"
+SCOURVER="0.24"
cd ..
zip scour/tarballs/scour-$SCOURVER.zip scour/scour.py scour/yocto_css.py scour/svg_regex.py scour/LICENSE scour/NOTICE scour/README.txt scour/release-notes.html
cd scour
diff --git a/release-notes.html b/release-notes.html
index b8f6502..140682c 100644
--- a/release-notes.html
+++ b/release-notes.html
@@ -9,11 +9,21 @@
Copyright 2009, Jeff Schiller
+
+
- 2009-01-04
+ 2010-01-04
- Fix Bug 482215 by using os.linesep to end lines
- Fix unittests to run properly in Windows
diff --git a/scour.py b/scour.py
index 700a034..bff9e2f 100755
--- a/scour.py
+++ b/scour.py
@@ -72,7 +72,7 @@ except ImportError:
pass
APP = 'scour'
-VER = '0.23'
+VER = '0.24'
COPYRIGHT = 'Copyright Jeff Schiller, 2010'
NS = { 'SVG': 'http://www.w3.org/2000/svg',
@@ -2021,20 +2021,14 @@ def remapNamespacePrefix(node, oldprefix, newprefix):
remapNamespacePrefix(child, oldprefix, newprefix)
def makeWellFormed(str):
- newstr = str
-
- # encode & as & ( must do this first so that < does not become < )
- if str.find('&') != -1:
- newstr = str.replace('&', '&')
+ newstr = ''
+ xml_ents = { '<':'<', '>':'>', '&':'&', "'":''', '"':'"'}
+ for c in str:
+ if c in xml_ents:
+ newstr += xml_ents[c]
+ else:
+ newstr += c
- # encode < as <
- if str.find("<") != -1:
- newstr = str.replace('<', '<')
-
- # encode > as > (TODO: is this necessary?)
- if str.find('>') != -1:
- newstr = str.replace('>', '>')
-
return newstr
# hand-rolled serialization function that has the following benefits:
@@ -2278,7 +2272,7 @@ def scourString(in_string, options=None):
embedRasters(elem, options)
# properly size the SVG document (ideally width/height should be 100% with a viewBox)
- if options.viewboxing:
+ if options.enable_viewboxing:
properlySizeDoc(doc.documentElement)
# output the document as a pretty string with a single space for indent
@@ -2354,7 +2348,7 @@ _options_parser.add_option("--strip-xml-prolog",
action="store_true", dest="strip_xml_prolog", default=False,
help="won't output the prolog")
_options_parser.add_option("--enable-viewboxing",
- action="store_true", dest="viewboxing", default=False,
+ action="store_true", dest="enable_viewboxing", default=False,
help="changes document width/height to 100%/100% and creates viewbox coordinates")
# GZ: this is confusing, most people will be thinking in terms of
diff --git a/testscour.py b/testscour.py
index b618e1f..126b4d3 100755
--- a/testscour.py
+++ b/testscour.py
@@ -47,7 +47,7 @@ class ScourOptions:
keep_editor_data = False
strip_xml_prolog = False
indent_type = "space"
- viewboxing = False
+ enable_viewboxing = False
class NoInkscapeElements(unittest.TestCase):
def runTest(self):
@@ -983,6 +983,11 @@ class EnsureLineEndings(unittest.TestCase):
self.assertEquals( len(s.splitlines()), 4,
'Did not output line ending character correctly')
+class XmlEntities(unittest.TestCase):
+ def runTest(self):
+ self.assertEquals( scour.makeWellFormed('<>&"\''), '<>&"'',
+ 'Incorrectly translated XML entities')
+
# TODO: write tests for --enable-viewboxing
# TODO; write a test for embedding rasters
# TODO: write a test for --disable-embed-rasters