From 587731583f4660dee49c217f69dfc73fe006d6cf Mon Sep 17 00:00:00 2001 From: Andy Coupe Date: Tue, 30 Jun 2020 14:40:57 +0100 Subject: [PATCH] improve lighthouse best practices audit (#863) * improve safety of cross origin links * add additional safety for cross origin links * remove duplicates --- ui/src/components/comment-form.tsx | 1 + ui/src/components/community.tsx | 1 + ui/src/components/iframely-card.tsx | 8 +++++++- ui/src/components/inbox.tsx | 1 + ui/src/components/main.tsx | 2 ++ ui/src/components/post-form.tsx | 2 ++ ui/src/components/post-listing.tsx | 4 ++++ ui/src/components/private-message-form.tsx | 2 ++ ui/src/components/sort-select.tsx | 1 + ui/src/components/sponsors.tsx | 2 +- ui/src/components/user.tsx | 8 +++++++- 11 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx index 45974cc07..72a604b9f 100644 --- a/ui/src/components/comment-form.tsx +++ b/ui/src/components/comment-form.tsx @@ -185,6 +185,7 @@ export class CommentForm extends Component { target="_blank" class="d-inline-block float-right text-muted font-weight-bold" title={i18n.t('formatting_help')} + rel="noopener" > diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx index 373d8f807..c193532b0 100644 --- a/ui/src/components/community.tsx +++ b/ui/src/components/community.tsx @@ -217,6 +217,7 @@ export class Community extends Component { }`} target="_blank" title="RSS" + rel="noopener" > # diff --git a/ui/src/components/iframely-card.tsx b/ui/src/components/iframely-card.tsx index 3a89023f5..0d3f43f69 100644 --- a/ui/src/components/iframely-card.tsx +++ b/ui/src/components/iframely-card.tsx @@ -44,7 +44,12 @@ export class IFramelyCard extends Component< ) : ( - + {post.embed_title} @@ -55,6 +60,7 @@ export class IFramelyCard extends Component< class="text-muted font-italic" target="_blank" href={post.url} + rel="noopener" > {new URL(post.url).hostname} diff --git a/ui/src/components/inbox.tsx b/ui/src/components/inbox.tsx index edbacd518..3b963a79f 100644 --- a/ui/src/components/inbox.tsx +++ b/ui/src/components/inbox.tsx @@ -109,6 +109,7 @@ export class Inbox extends Component { href={`/feeds/inbox/${UserService.Instance.auth}.xml`} target="_blank" title="RSS" + rel="noopener" > # diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index c168feb0c..4e04fe48c 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -452,6 +452,7 @@ export class Main extends Component { @@ -467,6 +468,7 @@ export class Main extends Component { }`} target="_blank" title="RSS" + rel="noopener" > # diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx index 9f5aa363e..fdf6ebe47 100644 --- a/ui/src/components/post-form.tsx +++ b/ui/src/components/post-form.tsx @@ -222,6 +222,7 @@ export class PostForm extends Component { )}`} target="_blank" class="mr-2 d-inline-block float-right text-muted small font-weight-bold" + rel="noopener" > {i18n.t('archive_link')} @@ -302,6 +303,7 @@ export class PostForm extends Component { diff --git a/ui/src/components/post-listing.tsx b/ui/src/components/post-listing.tsx index b4cc4f928..3d6088427 100644 --- a/ui/src/components/post-listing.tsx +++ b/ui/src/components/post-listing.tsx @@ -197,6 +197,7 @@ export class PostListing extends Component { className="text-body" href={post.url} target="_blank" + rel="noopener" title={post.url} > {this.imgThumb(this.getImage(true))} @@ -227,6 +228,7 @@ export class PostListing extends Component { href={post.url} target="_blank" title={post.url} + rel="noopener" > @@ -303,6 +305,7 @@ export class PostListing extends Component { href={post.url} target="_blank" title={post.url} + rel="noopener" > {post.name} @@ -323,6 +326,7 @@ export class PostListing extends Component { href={post.url} target="_blank" title={post.url} + rel="noopener" > {hostname(post.url)} diff --git a/ui/src/components/private-message-form.tsx b/ui/src/components/private-message-form.tsx index 8cb7590e6..107823615 100644 --- a/ui/src/components/private-message-form.tsx +++ b/ui/src/components/private-message-form.tsx @@ -175,6 +175,7 @@ export class PrivateMessageForm extends Component< # @@ -236,6 +237,7 @@ export class PrivateMessageForm extends Component< diff --git a/ui/src/components/sort-select.tsx b/ui/src/components/sort-select.tsx index a6ce2ea98..05abdb20a 100644 --- a/ui/src/components/sort-select.tsx +++ b/ui/src/components/sort-select.tsx @@ -47,6 +47,7 @@ export class SortSelect extends Component { className="text-muted" href={sortingHelpUrl} target="_blank" + rel="noopener" title={i18n.t('sorting_help')} > diff --git a/ui/src/components/sponsors.tsx b/ui/src/components/sponsors.tsx index 7e5eed642..06e135248 100644 --- a/ui/src/components/sponsors.tsx +++ b/ui/src/components/sponsors.tsx @@ -89,7 +89,7 @@ export class Sponsors extends Component { {silver.map(s => (
- + 💎 {s.name}
diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx index f635a1cd0..69914fd39 100644 --- a/ui/src/components/user.tsx +++ b/ui/src/components/user.tsx @@ -317,6 +317,7 @@ export class User extends Component { SortType[this.state.sort] }`} target="_blank" + rel="noopener" title="RSS" > @@ -463,6 +464,7 @@ export class User extends Component { !this.state.user.matrix_user_id && 'disabled' }`} target="_blank" + rel="noopener" href={`https://matrix.to/#/${this.state.user.matrix_user_id}`} > {i18n.t('send_secure_message')} @@ -586,7 +588,11 @@ export class User extends Component {