mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Tag needs escaping. Wrongly call showSuggestions.
close #2087, fix #2089 - escape tag. - do not call showSuggestions when key is UP/DOWN. or the selected tag will always be clear.
This commit is contained in:
parent
79e1356b66
commit
bcc57b677a
1 changed files with 10 additions and 10 deletions
|
@ -125,7 +125,7 @@
|
||||||
/*jslint regexp: true */ // - would like to remove this
|
/*jslint regexp: true */ // - would like to remove this
|
||||||
highlightedName = highlightedName.replace(/(<mark>[^<>]*)((<[^>]+>)+)([^<>]*<\/mark>)/, "$1</mark>$2<mark>$4");
|
highlightedName = highlightedName.replace(/(<mark>[^<>]*)((<[^>]+>)+)([^<>]*<\/mark>)/, "$1</mark>$2<mark>$4");
|
||||||
|
|
||||||
suggestionHTML = "<li data-tag-id='" + matchingTag.id + "' data-tag-name='" + matchingTag.name + "'><a href='#'>" + highlightedName + "</a></li>";
|
suggestionHTML = "<li data-tag-id='" + matchingTag.id + "' data-tag-name='" + _.escape(matchingTag.name) + "'><a href='#'>" + highlightedName + "</a></li>";
|
||||||
this.$suggestions.append(suggestionHTML);
|
this.$suggestions.append(suggestionHTML);
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
@ -134,12 +134,6 @@
|
||||||
var $target = $(e.currentTarget),
|
var $target = $(e.currentTarget),
|
||||||
searchTerm = $.trim($target.val());
|
searchTerm = $.trim($target.val());
|
||||||
|
|
||||||
if (searchTerm) {
|
|
||||||
this.showSuggestions($target, searchTerm);
|
|
||||||
} else {
|
|
||||||
this.$suggestions.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.keyCode === this.keys.UP) {
|
if (e.keyCode === this.keys.UP) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.$suggestions.is(":visible")) {
|
if (this.$suggestions.is(":visible")) {
|
||||||
|
@ -160,6 +154,12 @@
|
||||||
}
|
}
|
||||||
} else if (e.keyCode === this.keys.ESC) {
|
} else if (e.keyCode === this.keys.ESC) {
|
||||||
this.$suggestions.hide();
|
this.$suggestions.hide();
|
||||||
|
} else {
|
||||||
|
if (searchTerm) {
|
||||||
|
this.showSuggestions($target, searchTerm);
|
||||||
|
} else {
|
||||||
|
this.$suggestions.hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.keyCode === this.keys.UP || e.keyCode === this.keys.DOWN) {
|
if (e.keyCode === this.keys.UP || e.keyCode === this.keys.DOWN) {
|
||||||
|
@ -195,8 +195,8 @@
|
||||||
$selectedSuggestion = this.$suggestions.children(".selected");
|
$selectedSuggestion = this.$suggestions.children(".selected");
|
||||||
if (this.$suggestions.is(":visible") && $selectedSuggestion.length !== 0) {
|
if (this.$suggestions.is(":visible") && $selectedSuggestion.length !== 0) {
|
||||||
|
|
||||||
if ($('.tag:containsExact("' + $selectedSuggestion.data('tag-name') + '")').length === 0) {
|
if ($('.tag:containsExact("' + _.unescape($selectedSuggestion.data('tag-name')) + '")').length === 0) {
|
||||||
tag = {id: $selectedSuggestion.data('tag-id'), name: $selectedSuggestion.data('tag-name')};
|
tag = {id: $selectedSuggestion.data('tag-id'), name: _.unescape($selectedSuggestion.data('tag-name'))};
|
||||||
this.addTag(tag);
|
this.addTag(tag);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -232,7 +232,7 @@
|
||||||
handleSuggestionClick: function (e) {
|
handleSuggestionClick: function (e) {
|
||||||
var $target = $(e.currentTarget);
|
var $target = $(e.currentTarget);
|
||||||
if (e) { e.preventDefault(); }
|
if (e) { e.preventDefault(); }
|
||||||
this.addTag({id: $target.data('tag-id'), name: $target.data('tag-name')});
|
this.addTag({id: $target.data('tag-id'), name: _.unescape($target.data('tag-name'))});
|
||||||
},
|
},
|
||||||
|
|
||||||
handleTagClick: function (e) {
|
handleTagClick: function (e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue