<% if (ctx.canViewUsers) { %>
-
+
<% } %>
- <%= user.name %>
+ <%- user.name %>
<% if (ctx.canViewUsers) { %>
<% } %>
diff --git a/client/js/controls/tag_auto_complete_control.js b/client/js/controls/tag_auto_complete_control.js
index b54e461..731a366 100644
--- a/client/js/controls/tag_auto_complete_control.js
+++ b/client/js/controls/tag_auto_complete_control.js
@@ -28,8 +28,9 @@ class TagAutoCompleteControl extends AutoCompleteControl {
return kv2[1].usages - kv1[1].usages;
})
.map(kv => {
+ const origName = misc.escapeHtml(
+ tags.getOriginalTagName(kv[0]));
const category = kv[1].category;
- const origName = tags.getOriginalTagName(kv[0]);
const usages = kv[1].usages;
const cssName = misc.makeCssName(category, 'tag');
return {
diff --git a/client/js/util/misc.js b/client/js/util/misc.js
index e6bcdec..5e2297a 100644
--- a/client/js/util/misc.js
+++ b/client/js/util/misc.js
@@ -224,6 +224,15 @@ function makeCssName(text, suffix) {
return suffix + '-' + text.replace(/[^a-z0-9]/g, '_');
}
+function escapeHtml(unsafe) {
+ return unsafe
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+}
+
module.exports = {
range: range,
formatSearchQuery: formatSearchQuery,
@@ -236,5 +245,6 @@ module.exports = {
enableExitConfirmation: enableExitConfirmation,
disableExitConfirmation: disableExitConfirmation,
confirmPageExit: confirmPageExit,
+ escapeHtml: escapeHtml,
makeCssName: makeCssName,
};
diff --git a/client/js/util/views.js b/client/js/util/views.js
index 7c5c60f..b3b401a 100644
--- a/client/js/util/views.js
+++ b/client/js/util/views.js
@@ -198,7 +198,8 @@ function _serializeElement(name, attributes) {
attributes[key] === undefined) {
return '';
}
- return `${key}="${attributes[key]}"`;
+ const attribute = misc.escapeHtml(attributes[key] || '');
+ return `${key}="${attribute}"`;
}))
.join(' ');
}
@@ -446,7 +447,6 @@ module.exports = {
replaceContent: replaceContent,
enableForm: enableForm,
disableForm: disableForm,
- clearMessages: clearMessages,
decorateValidator: decorateValidator,
makeVoidElement: makeVoidElement,
makeNonVoidElement: makeNonVoidElement,
@@ -454,6 +454,7 @@ module.exports = {
slideDown: slideDown,
slideUp: slideUp,
monitorNodeRemoval: monitorNodeRemoval,
+ clearMessages: clearMessages,
showError: showError,
showSuccess: showSuccess,
showInfo: showInfo,