1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-03 23:05:50 +01:00

Fix dtd generation bug.

This commit is contained in:
Kris Maglione
2011-03-16 01:56:20 -04:00
parent 222ef1c16a
commit ba4b07a593
2 changed files with 8 additions and 6 deletions

View File

@@ -749,12 +749,14 @@ var Options = Module("options", {
opt.set(opt.globalValue, Option.SCOPE_GLOBAL, true);
}, window);
function escape(str) str.replace(/[<&]/g, function (m) ({ "&": "&amp;", "<": "&lt;" })[m]);
services["dactyl:"].pages["options.dtd"] = function () [null,
util.makeDTD(
iter(([["option", o.name, "default"].join("."),
o.type === "string" ? o.defaultValue.replace(/'/g, "''") :
o.value === true ? "on" :
o.value === false ? "off" : o.stringDefaultValue]
escape(o.type === "string" ? o.defaultValue.replace(/'/g, "''") :
o.value === true ? "on" :
o.value === false ? "off" : o.stringDefaultValue)]
for (o in self)),
([["option", o.name, "type"].join("."), o.type] for (o in self)),

View File

@@ -975,9 +975,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
},
makeDTD: function makeDTD(obj) unescape(encodeURI(iter(obj)
.map(function ([k, v]) ["<!ENTITY ", k, ' "', String.replace(v == null ? "null" : v, /[&"<%]/g,
function (m) ({ '"': "&quot;", "&": "&amp;", "<": "&lt;", "%": "&#x25;" })[m]),
'">'].join(""))
.map(function ([k, v]) ["<!ENTITY ", k, " '", String.replace(v == null ? "null" : v, /['%]/g,
function (m) ({ "'": "&apos;", "%": "&#x25;" })[m]),
"'>"].join(""))
.join("\n"))),
map: deprecated("iter.map", function map(obj, fn, self) iter(obj).map(fn, self).toArray()),