client: rename escapeColons to escapeTagName and also escape dots
This commit is contained in:
parent
545b5828b5
commit
7c37734fec
9 changed files with 11 additions and 11 deletions
|
@ -92,7 +92,7 @@
|
|||
--></a><!--
|
||||
--><% } %><!--
|
||||
--><% if (ctx.canListPosts) { %><!--
|
||||
--><a href='<%- ctx.formatClientLink('posts', {query: ctx.escapeColons(tag.names[0])}) %>' class='<%= ctx.makeCssName(tag.category, 'tag') %>'><!--
|
||||
--><a href='<%- ctx.formatClientLink('posts', {query: ctx.escapeTagName(tag.names[0])}) %>' class='<%= ctx.makeCssName(tag.category, 'tag') %>'><!--
|
||||
--><% } %><!--
|
||||
--><%- ctx.getPrettyName(tag.names[0]) %> <!--
|
||||
--><% if (ctx.canListPosts) { %><!--
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class='tag-delete'>
|
||||
<form>
|
||||
<p>This tag has <a href='<%- ctx.formatClientLink('posts', {query: ctx.escapeColons(ctx.tag.names[0])}) %>'><%- ctx.tag.postCount %> usage(s)</a>.</p>
|
||||
<p>This tag has <a href='<%- ctx.formatClientLink('posts', {query: ctx.escapeTagName(ctx.tag.names[0])}) %>'><%- ctx.tag.postCount %> usage(s)</a>.</p>
|
||||
|
||||
<ul class='input'>
|
||||
<li>
|
||||
|
|
|
@ -36,6 +36,6 @@
|
|||
<section class='description'>
|
||||
<hr/>
|
||||
<%= ctx.makeMarkdown(ctx.tag.description || 'This tag has no description yet.') %>
|
||||
<p>This tag has <a href='<%- ctx.formatClientLink('posts', {query: ctx.escapeColons(ctx.tag.names[0])}) %>'><%- ctx.tag.postCount %> usage(s)</a>.</p>
|
||||
<p>This tag has <a href='<%- ctx.formatClientLink('posts', {query: ctx.escapeTagName(ctx.tag.names[0])}) %>'><%- ctx.tag.postCount %> usage(s)</a>.</p>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
@ -52,7 +52,7 @@ class PoolController {
|
|||
canMerge: api.hasPrivilege("pools:merge"),
|
||||
canDelete: api.hasPrivilege("pools:delete"),
|
||||
categories: categories,
|
||||
escapeColons: uri.escapeColons,
|
||||
escapeTagName: uri.escapeTagName,
|
||||
});
|
||||
|
||||
this._view.addEventListener("change", (e) =>
|
||||
|
|
|
@ -26,7 +26,7 @@ class PoolCreateController {
|
|||
this._view = new PoolCreateView({
|
||||
canCreate: api.hasPrivilege("pools:create"),
|
||||
categories: categories,
|
||||
escapeColons: uri.escapeColons,
|
||||
escapeTagName: uri.escapeTagName,
|
||||
});
|
||||
|
||||
this._view.addEventListener("submit", (e) =>
|
||||
|
|
|
@ -56,7 +56,7 @@ class TagController {
|
|||
canMerge: api.hasPrivilege("tags:merge"),
|
||||
canDelete: api.hasPrivilege("tags:delete"),
|
||||
categories: categories,
|
||||
escapeColons: uri.escapeColons,
|
||||
escapeTagName: uri.escapeTagName,
|
||||
});
|
||||
|
||||
this._view.addEventListener("change", (e) =>
|
||||
|
|
|
@ -28,7 +28,7 @@ class PostReadonlySidebarControl extends events.EventTarget {
|
|||
canListPosts: api.hasPrivilege("posts:list"),
|
||||
canEditPosts: api.hasPrivilege("posts:edit"),
|
||||
canViewTags: api.hasPrivilege("tags:view"),
|
||||
escapeColons: uri.escapeColons,
|
||||
escapeTagName: uri.escapeTagName,
|
||||
extractRootDomain: uri.extractRootDomain,
|
||||
getPrettyName: misc.getPrettyName,
|
||||
})
|
||||
|
|
|
@ -305,7 +305,7 @@ class TagInputControl extends events.EventTarget {
|
|||
searchLinkNode.setAttribute(
|
||||
"href",
|
||||
uri.formatClientLink("posts", {
|
||||
query: uri.escapeColons(tag.names[0]),
|
||||
query: uri.escapeTagName(tag.names[0]),
|
||||
})
|
||||
);
|
||||
searchLinkNode.textContent = tag.names[0] + " ";
|
||||
|
|
|
@ -85,14 +85,14 @@ function extractRootDomain(url) {
|
|||
return domain;
|
||||
}
|
||||
|
||||
function escapeColons(text) {
|
||||
return text.replace(new RegExp(":", "g"), "\\:");
|
||||
function escapeTagName(text) {
|
||||
return text.replace(/:/g, "\\:").replace(/\./g, "\\.");
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatClientLink: formatClientLink,
|
||||
formatApiLink: formatApiLink,
|
||||
escapeColons: escapeColons,
|
||||
escapeTagName: escapeTagName,
|
||||
escapeParam: escapeParam,
|
||||
unescapeParam: unescapeParam,
|
||||
extractHostname: extractHostname,
|
||||
|
|
Loading…
Reference in a new issue