From dbc2f42399f5b628279703958cdb963571af04e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=93=E3=81=B4=E3=81=AA=E3=81=9F=E3=81=BF=E3=81=BD?= Date: Fri, 23 Feb 2018 18:34:14 +0900 Subject: [PATCH] Fix #1124 --- .../app/common/views/components/post-html.ts | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/web/app/common/views/components/post-html.ts b/src/web/app/common/views/components/post-html.ts index 006e326849..37954cd7e7 100644 --- a/src/web/app/common/views/components/post-html.ts +++ b/src/web/app/common/views/components/post-html.ts @@ -1,15 +1,8 @@ -declare const _URL_: string; - import Vue from 'vue'; import * as pictograph from 'pictograph'; - +import { url } from '../../../config'; import MkUrl from './url.vue'; -const escape = text => - text - .replace(/>/g, '>') - .replace(/ { switch (token.type) { case 'text': - const text = escape(token.content) - .replace(/(\r\n|\n|\r)/g, '\n'); + const text = token.content.replace(/(\r\n|\n|\r)/g, '\n'); if ((this as any).shouldBreak) { if (text.indexOf('\n') != -1) { - const x = text.split('\n').map(t => [createElement('span', t), createElement('br')]); + const x = text.split('\n') + .map(t => [createElement('span', t), createElement('br')]); x[x.length - 1].pop(); return x; } else { @@ -45,12 +38,12 @@ export default Vue.component('mk-post-html', { } case 'bold': - return createElement('strong', escape(token.bold)); + return createElement('strong', token.bold); case 'url': return createElement(MkUrl, { props: { - url: escape(token.content), + url: token.content, target: '_blank' } }); @@ -59,16 +52,16 @@ export default Vue.component('mk-post-html', { return createElement('a', { attrs: { class: 'link', - href: escape(token.url), + href: token.url, target: '_blank', - title: escape(token.url) + title: token.url } - }, escape(token.title)); + }, token.title); case 'mention': return (createElement as any)('a', { attrs: { - href: `${_URL_}/${escape(token.username)}`, + href: `${url}/${token.username}`, target: '_blank', dataIsMe: (this as any).i && (this as any).i.username == token.username }, @@ -81,10 +74,10 @@ export default Vue.component('mk-post-html', { case 'hashtag': return createElement('a', { attrs: { - href: `${_URL_}/search?q=${escape(token.content)}`, + href: `${url}/search?q=${token.content}`, target: '_blank' } - }, escape(token.content)); + }, token.content); case 'code': return createElement('pre', [