fix sanitarization fiendica

This commit is contained in:
Nicolas Constant 2019-05-23 02:16:36 -04:00
parent 0e9bff10f6
commit b2cad5fd8a
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
1 changed files with 8 additions and 6 deletions

View File

@ -27,7 +27,9 @@ export class DatabindedTextComponent implements OnInit {
this.processedText = ''; this.processedText = '';
value = value.replace('@<span class="">', '<span class="">'); //Friendica sanitarization do {
value = value.replace('@<span class="">', '<span class="">'); //Friendica sanitarization
} while (value.includes('@<span class="">'));
let linksSections = value.split('<a '); let linksSections = value.split('<a ');
@ -80,7 +82,7 @@ export class DatabindedTextComponent implements OnInit {
let extractedAccountAndNext: string[]; let extractedAccountAndNext: string[];
let extractedAccountName: string; let extractedAccountName: string;
if(section.includes('<span class="mention">')){ //Friendica if (section.includes('<span class="mention">')) { //Friendica
extractedAccountAndNext = section.split('</a>'); extractedAccountAndNext = section.split('</a>');
extractedAccountName = extractedAccountAndNext[0].split('<span class="mention">')[1].split('</span>')[0]; extractedAccountName = extractedAccountAndNext[0].split('<span class="mention">')[1].split('</span>')[0];
} else if (!section.includes('@<span>')) { //GNU social } else if (!section.includes('@<span>')) { //GNU social
@ -101,11 +103,11 @@ export class DatabindedTextComponent implements OnInit {
let classname = this.getClassNameForAccount(extractedAccount); let classname = this.getClassNameForAccount(extractedAccount);
this.processedText += `<a href class="${classname}" title="${extractedAccount}">@${extractedAccountName}</a>`; this.processedText += `<a href class="${classname}" title="${extractedAccount}">@${extractedAccountName}</a>`;
if (extractedAccountAndNext[1]) if (extractedAccountAndNext[1])
this.processedText += extractedAccountAndNext[1]; this.processedText += extractedAccountAndNext[1];
//GNU Social clean up //GNU Social clean up
if(this.processedText.includes('@<a')) if (this.processedText.includes('@<a'))
this.processedText = this.processedText.replace('@<a', '<a'); this.processedText = this.processedText.replace('@<a', '<a');
this.accounts.push(extractedAccount); this.accounts.push(extractedAccount);
@ -180,10 +182,10 @@ export class DatabindedTextComponent implements OnInit {
}); });
this.renderer.listen(el, 'mouseup', (event) => { this.renderer.listen(el, 'mouseup', (event) => {
if(event.which === 2){ if (event.which === 2) {
event.preventDefault(); event.preventDefault();
event.stopImmediatePropagation(); event.stopImmediatePropagation();
window.open(link, '_blank'); window.open(link, '_blank');
return false; return false;
} }