- From: Robin Berjon via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 02 May 2011 10:09:38 +0000
- To: public-dap-commits@w3.org
Update of /sources/public/2009/dap/ReSpec.js/js In directory hutz:/tmp/cvs-serv1122/js Modified Files: respec.js simple-node.js Log Message: sanitise generated IDs Index: respec.js =================================================================== RCS file: /sources/public/2009/dap/ReSpec.js/js/respec.js,v retrieving revision 1.148 retrieving revision 1.149 diff -u -d -r1.148 -r1.149 --- respec.js 29 Apr 2011 14:06:57 -0000 1.148 +++ respec.js 2 May 2011 10:09:36 -0000 1.149 @@ -2150,7 +2150,7 @@ params.push(prm.datatype + (prm.array ? "Array" : "") + "-" + prm.id) } id += params.join("-"); - return id; + return sn.sanitiseID(id); // return sn.idThatDoesNotExist(id); }, Index: simple-node.js =================================================================== RCS file: /sources/public/2009/dap/ReSpec.js/js/simple-node.js,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- simple-node.js 29 Apr 2011 14:11:26 -0000 1.8 +++ simple-node.js 2 May 2011 10:09:36 -0000 1.9 @@ -112,14 +112,19 @@ id += txt; id = id.toLowerCase(); if (id.length == 0) id = "generatedID"; + id = this.sanitiseID(id); + if (pfx) id = pfx + "-" + id; + id = this.idThatDoesNotExist(id); + el.setAttribute("id", id); + return id; + }, + + sanitiseID: function (id) { id = id.split(/[^-.0-9a-z_]/).join("-"); id = id.replace(/^-+/, ""); id = id.replace(/-+$/, ""); if (id.length > 0 && /^[^a-z]/.test(id)) id = "x" + id; if (id.length == 0) id = "generatedID"; - if (pfx) id = pfx + "-" + id; - id = this.idThatDoesNotExist(id); - el.setAttribute("id", id); return id; },
Received on Monday, 2 May 2011 10:09:39 UTC