Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 3cded9b

Browse files
committed
bug(locators): escape query in byExactBinding
See http://stackoverflow.com/q/3561711 Closes #1918
1 parent de49969 commit 3cded9b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/clientsidescripts.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ functions.findBindings = function(binding, exactMatch, using, rootSelector) {
7272
if (dataBinding) {
7373
var bindingName = dataBinding.exp || dataBinding[0].exp || dataBinding;
7474
if (exactMatch) {
75-
var matcher = new RegExp('({|\\s|^|\\|)' + binding + '(}|\\s|$|\\|)');
75+
var matcher = new RegExp('({|\\s|^|\\|)' +
76+
/* See http://stackoverflow.com/q/3561711 */
77+
binding.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") +
78+
'(}|\\s|$|\\|)');
7679
if (matcher.test(bindingName)) {
7780
matches.push(bindings[i]);
7881
}

website/docgen/inline_tags/code.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
var htmlSpecialCharMap = {
2+
"&": "&",
3+
"<": "&lt;",
4+
">": "&gt;",
5+
'"': '&quot;',
6+
"'": '&#39;',
7+
"/": '&#x2F;'
8+
};
9+
110
module.exports = function codeTagDef() {
211
return {
312
name: 'code',
413
handler: function(doc, tag, content) {
5-
return '<code ng-non-bindable>' + content + '</code>';
14+
return '<code ng-non-bindable>' +
15+
content.replace(/[&<>"'\/]/g, function (s) {
16+
return htmlSpecialCharMap[s];
17+
}) + '</code>';
618
},
719
description: 'Handle inline code tags',
820
aliases: ['monospace']

0 commit comments

Comments
 (0)