Support rel="me" links in markdown

pull/2654/head
Chocobozzz 2020-04-16 16:12:10 +02:00
parent 5600def4c8
commit 891bc2ffad
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 8 additions and 4 deletions

View File

@ -1,7 +1,7 @@
import { I18n } from '@ngx-translate/i18n-polyfill' import { I18n } from '@ngx-translate/i18n-polyfill'
import { Validators, ValidatorFn } from '@angular/forms' import { Validators, ValidatorFn } from '@angular/forms'
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { BuildFormValidator, validateHost } from '@app/shared' import { BuildFormValidator, validateHost } from '@app/shared/forms/form-validators'
@Injectable() @Injectable()
export class BatchDomainsValidatorsService { export class BatchDomainsValidatorsService {

View File

@ -12,7 +12,8 @@ import { ClientHook, ClientHookName, clientHookObject } from '@shared/models/plu
import { PluginClientScope } from '@shared/models/plugins/plugin-client-scope.type' import { PluginClientScope } from '@shared/models/plugins/plugin-client-scope.type'
import { RegisterClientHookOptions } from '@shared/models/plugins/register-client-hook.model' import { RegisterClientHookOptions } from '@shared/models/plugins/register-client-hook.model'
import { HttpClient } from '@angular/common/http' import { HttpClient } from '@angular/common/http'
import { AuthService, Notifier } from '@app/core' import { AuthService } from '@app/core/auth'
import { Notifier } from '@app/core/notification'
import { RestExtractor } from '@app/shared/rest' import { RestExtractor } from '@app/shared/rest'
import { PluginType } from '@shared/models/plugins/plugin.type' import { PluginType } from '@shared/models/plugins/plugin.type'
import { PublicServerSetting } from '@shared/models/plugins/public-server.setting' import { PublicServerSetting } from '@shared/models/plugins/public-server.setting'

View File

@ -19,15 +19,18 @@ export class HtmlRendererService {
allowedTags: [ 'a', 'p', 'span', 'br', 'strong', 'em', 'ul', 'ol', 'li' ], allowedTags: [ 'a', 'p', 'span', 'br', 'strong', 'em', 'ul', 'ol', 'li' ],
allowedSchemes: [ 'http', 'https' ], allowedSchemes: [ 'http', 'https' ],
allowedAttributes: { allowedAttributes: {
'a': [ 'href', 'class', 'target' ] 'a': [ 'href', 'class', 'target', 'rel' ]
}, },
transformTags: { transformTags: {
a: (tagName, attribs) => { a: (tagName, attribs) => {
let rel = 'noopener noreferrer'
if (attribs.rel === 'me') rel += ' me'
return { return {
tagName, tagName,
attribs: Object.assign(attribs, { attribs: Object.assign(attribs, {
target: '_blank', target: '_blank',
rel: 'noopener noreferrer' rel
}) })
} }
} }