summaryrefslogtreecommitdiff
path: root/licensing
diff options
context:
space:
mode:
authorYu-Ju Hong <yjhong@chromium.org>2013-11-18 23:25:29 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-11-19 21:22:56 +0000
commit6df6b24ee6f9d3d124fcd1592484a843cab96594 (patch)
tree94f4b0d323e4dc1655b726125da1b80b9f55cfa7 /licensing
parentb9dc73e61a85878f065bf1a1f7e426e8d377f8e9 (diff)
downloadchromite-6df6b24ee6f9d3d124fcd1592484a843cab96594.tar.gz
licensing: fix HTML escaping
This CL fixes two HTML escaping issues complained by xmllint. In licenses.py, HTML escaping should be done right before evaluting the template to make sure it is performed once (and only once) for every license file. This change ensures that all URLs and author emails in the license files are properly displayed. In the template itself, the block of code surrounded by tag <script></script> should be marked as a CDATA section so that it can be ignored by the XML parser. BUG=chromium:317103 BUG=chromium:318909 TEST=Run the script locally and verify the output, pass xmllint Change-Id: I1b1a7ac35532f2918bcf70031db7b7cb69b7f4fa Reviewed-on: https://chromium-review.googlesource.com/177287 Reviewed-by: Mike Frysinger <vapier@chromium.org> Tested-by: Yu-Ju Hong <yjhong@chromium.org> Commit-Queue: Yu-Ju Hong <yjhong@chromium.org>
Diffstat (limited to 'licensing')
-rw-r--r--licensing/about_credits.tmpl2
-rw-r--r--licensing/licenses.py6
2 files changed, 5 insertions, 3 deletions
diff --git a/licensing/about_credits.tmpl b/licensing/about_credits.tmpl
index 056639358..a1a1bc58f 100644
--- a/licensing/about_credits.tmpl
+++ b/licensing/about_credits.tmpl
@@ -55,6 +55,7 @@ body {
}
</style>
<script>
+//<![CDATA[
function $(o) {return document.getElementById(o);}
function toggle(o) {
var licence = o.nextSibling;
@@ -73,6 +74,7 @@ function toggle(o) {
}
return false;
}
+//]]>
</script>
</head>
<body>
diff --git a/licensing/licenses.py b/licensing/licenses.py
index 2976a4263..16a72188e 100644
--- a/licensing/licenses.py
+++ b/licensing/licenses.py
@@ -930,8 +930,8 @@ to third_party/chromiumos-overlay/licenses/""" %
env = {
'name': "%s-%s" % (package.name, package.version),
- 'url': package.homepages[0] if package.homepages else '',
- 'licenses_txt': '\n'.join(license_text) or '',
+ 'url': cgi.escape(package.homepages[0]) if package.homepages else '',
+ 'licenses_txt': cgi.escape('\n'.join(license_text)) or '',
'licenses_ptr': '\n'.join(license_pointers) or '',
}
self.package_text[package] = self.EvaluateTemplate(self.entry_template, env)
@@ -962,7 +962,7 @@ to third_party/chromiumos-overlay/licenses/""" %
logging.info("Collapsing shared license %s into single use license "
"(only used by %s)", sln, pkg_fullnamerev)
license_type = self._FindLicenseType(sln)
- license_txt = cgi.escape(self._ReadSharedLicense(sln))
+ license_txt = self._ReadSharedLicense(sln)
single_license = "%s License %s:\n\n%s" % (license_type, sln,
license_txt)
pkg = self.packages[pkg_fullnamerev]