[open-ils-commits] r9969 - in trunk: Open-ILS/web/opac/locale/en-US
build/i18n/tests
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Jul 6 12:01:51 EDT 2008
Author: dbs
Date: 2008-07-06 12:01:49 -0400 (Sun, 06 Jul 2008)
New Revision: 9969
Modified:
trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
trunk/build/i18n/tests/check_entities.py
Log:
Tighten up our entity checks; include a more complete range of legal entity chars
Add a missing entity discovered by our more stringent entity tests
Modified: trunk/Open-ILS/web/opac/locale/en-US/lang.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/lang.dtd 2008-07-05 18:01:22 UTC (rev 9968)
+++ trunk/Open-ILS/web/opac/locale/en-US/lang.dtd 2008-07-06 16:01:49 UTC (rev 9969)
@@ -2026,6 +2026,7 @@
<!ENTITY staff.cat.z3950.catalog_service.tooltiptext "Evergreen Native Catalog">
<!ENTITY staff.cat.z3950.save_creds.label "Save as Default">
<!ENTITY staff.cat.z3950.save_creds.accesskey "D">
+<!ENTITY staff.cat.z3950.query.description "Description">
<!ENTITY staff.cat.z3950.query.label "Query">
<!ENTITY staff.cat.z3950.query.label "Tip: Click a search field label and then the 'Save as Default' button to have that field focused by default.">
<!ENTITY staff.cat.z3950.clear.label "Clear Form">
Modified: trunk/build/i18n/tests/check_entities.py
===================================================================
--- trunk/build/i18n/tests/check_entities.py 2008-07-05 18:01:22 UTC (rev 9968)
+++ trunk/build/i18n/tests/check_entities.py 2008-07-06 16:01:49 UTC (rev 9969)
@@ -62,6 +62,8 @@
prefix = os.path.commonprefix(dtd_files)
for d_file in dtd_files:
+ if DEBUG:
+ print "Checking %s\n" % (d_file)
# Get the shortest unique address for this file
short_df = d_file[len(prefix):]
@@ -79,7 +81,7 @@
# Parse entity/value
unpack = re.search(r'<!ENTITY\s+(.+?)\s+([\'"])(.*?)\2\s*>', line)
if DEBUG and unpack:
- print unpack.groups()
+ print(unpack.groups())
# Skip anything other than entity definitions
# Note that this makes some massive assumptions:
@@ -96,7 +98,7 @@
entity_key, quote, value = unpack.groups()
if DEBUG:
- print entity_key, value
+ print(entity_key, value)
if not entities.has_key(entity_key):
entities[entity_key] = [{'value': value, 'file': short_df}]
@@ -139,23 +141,35 @@
# Typical entity usage:
# &blah.blah.blah_bity.blah;
- strings = re.compile(r'''&([a-zA-Z._]+);''')
+ strings = re.compile(r'''&([a-zA-Z:_][a-zA-Z0-9:_\-.]+);''')
xul = open(os.path.join(root, filename), 'r')
content = xul.read()
xul.close()
if DEBUG:
- print "File: %s" % (os.path.normpath(os.path.join(root, filename)))
+ print("File: %s" % (os.path.normpath(os.path.join(root, filename))))
for s_match in strings.finditer(content):
num_strings += 1
if not entities.has_key(s_match.group(1)):
- print "File: %s" % (os.path.normpath(os.path.join(root, filename)))
- print "\tEntity %s not found, expected in %s" % (s_match.group(1), 'lang.dtd')
+ print("File: %s" % (os.path.normpath(os.path.join(root, filename))))
+ print("\tEntity %s not found, expected in %s" % (s_match.group(1), 'lang.dtd'))
+ # Find bad entities
+ bad_strings = re.compile(r'''&([^a-zA-Z:_]?[a-zA-Z0-9:_]*[^a-zA-Z0-9:_\-.;][a-zA-Z0-9:_\-.]*);''')
+
+ # Match character entities ( etc), which are okay
+ char_entity = re.compile(r'''^((#([0-9])+)|(#x([0-9a-fA-F])+))$''')
+
+ for s_match in bad_strings.finditer(content):
+ # Rule out character entities and URL concatenation
+ if (not char_entity.search(s_match.group(1))) and s_match.group(1) != "'":
+ print("File: %s" % (os.path.normpath(os.path.join(root, filename))))
+ print("\tBad entity: %s" % (s_match.group(1)))
+
if DEBUG:
- print "\t%d entities found" % (num_strings)
+ print("\t%d entities found" % (num_strings))
if __name__ == '__main__':
entities = parse_entities()
More information about the open-ils-commits
mailing list