mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-12-22 13:17:13 +00:00
Fix verified badge in account lists potentially including rel="me" links (#25561)
This commit is contained in:
parent
a985d587e1
commit
55e7c08a83
|
@ -1,11 +1,27 @@
|
||||||
import { Icon } from './icon';
|
import { Icon } from './icon';
|
||||||
|
|
||||||
|
const domParser = new DOMParser();
|
||||||
|
|
||||||
|
const stripRelMe = (html: string) => {
|
||||||
|
const document = domParser.parseFromString(html, 'text/html').documentElement;
|
||||||
|
|
||||||
|
document.querySelectorAll<HTMLAnchorElement>('a[rel]').forEach((link) => {
|
||||||
|
link.rel = link.rel
|
||||||
|
.split(' ')
|
||||||
|
.filter((x: string) => x !== 'me')
|
||||||
|
.join(' ');
|
||||||
|
});
|
||||||
|
|
||||||
|
const body = document.querySelector('body');
|
||||||
|
return body ? { __html: body.innerHTML } : undefined;
|
||||||
|
};
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
link: string;
|
link: string;
|
||||||
}
|
}
|
||||||
export const VerifiedBadge: React.FC<Props> = ({ link }) => (
|
export const VerifiedBadge: React.FC<Props> = ({ link }) => (
|
||||||
<span className='verified-badge'>
|
<span className='verified-badge'>
|
||||||
<Icon id='check' className='verified-badge__mark' />
|
<Icon id='check' className='verified-badge__mark' />
|
||||||
<span dangerouslySetInnerHTML={{ __html: link }} />
|
<span dangerouslySetInnerHTML={stripRelMe(link)} />
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue