Remove remote class from HTML
This commit is contained in:
parent
b35127e172
commit
dff2e95369
3 changed files with 18 additions and 13 deletions
|
@ -97,17 +97,12 @@
|
|||
.comment-html {
|
||||
@include peertube-word-wrap;
|
||||
|
||||
// Mentions
|
||||
::ng-deep a {
|
||||
color: pvar(--fg);
|
||||
|
||||
&:not(.linkified-url) {
|
||||
color: pvar(--fg);
|
||||
|
||||
font-weight: $font-semibold;
|
||||
|
||||
@include disable-default-a-behaviour;
|
||||
}
|
||||
font-weight: $font-semibold;
|
||||
|
||||
@include disable-default-a-behaviour;
|
||||
}
|
||||
|
||||
// Paragraphs
|
||||
|
|
|
@ -22,7 +22,7 @@ export class HtmlRendererService {
|
|||
this.addHrefHook(this.enhancedDomPurify)
|
||||
|
||||
this.addCheckSchemesHook(this.simpleDomPurify, getDefaultSanitizedSchemes())
|
||||
this.addCheckSchemesHook(this.simpleDomPurify, [ ...getDefaultSanitizedSchemes(), 'mailto' ])
|
||||
this.addCheckSchemesHook(this.enhancedDomPurify, [ ...getDefaultSanitizedSchemes(), 'mailto' ])
|
||||
}
|
||||
|
||||
private addHrefHook (dompurifyInstance: DOMPurifyI) {
|
||||
|
@ -72,8 +72,17 @@ export class HtmlRendererService {
|
|||
})
|
||||
}
|
||||
|
||||
removeClassAttributes (html: string) {
|
||||
return DOMPurify().sanitize(html, {
|
||||
ALLOWED_TAGS: getDefaultSanitizedTags(),
|
||||
ALLOWED_ATTR: getDefaultSanitizedHrefAttributes().filter(a => a !== 'class'),
|
||||
ALLOW_DATA_ATTR: true
|
||||
})
|
||||
}
|
||||
|
||||
async toSimpleSafeHtml (text: string) {
|
||||
const html = await this.linkifier.linkify(text)
|
||||
let html = this.removeClassAttributes(text)
|
||||
html = await this.linkifier.linkify(html)
|
||||
|
||||
return this.sanitize(this.simpleDomPurify, html)
|
||||
}
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
import { Injectable } from '@angular/core'
|
||||
import { getAbsoluteAPIUrl } from '@app/helpers/utils'
|
||||
import * as LinkifyJS from 'linkifyjs'
|
||||
import type * as LinkifyJS from 'linkifyjs'
|
||||
import type LinkifyHTML from 'linkify-html'
|
||||
|
||||
@Injectable()
|
||||
export class LinkifierService {
|
||||
static CLASSNAME = 'linkified'
|
||||
|
||||
private linkifyModule: typeof LinkifyJS
|
||||
private linkifyHtmlModule: any
|
||||
private linkifyHtmlModule: typeof LinkifyHTML
|
||||
|
||||
private mentionPluginInitialized = false
|
||||
|
||||
private linkifyOptions = {
|
||||
private linkifyOptions: LinkifyJS.Opts = {
|
||||
className: {
|
||||
mention: LinkifierService.CLASSNAME + '-mention',
|
||||
url: LinkifierService.CLASSNAME + '-url'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue