Adding nofollow to links. Fixes #542 (#543)

* Adding nofollow to links. Fixes #542

* Running prettier.
This commit is contained in:
Dessalines 2022-02-24 15:31:44 +00:00 committed by GitHub
parent 2663e19fdc
commit 6684bbeaf6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 42 additions and 27 deletions

View file

@ -10,6 +10,7 @@ import {
mdToHtml, mdToHtml,
pictrsDeleteToast, pictrsDeleteToast,
randomStr, randomStr,
relTags,
setupTippy, setupTippy,
setupTribute, setupTribute,
toast, toast,
@ -297,7 +298,7 @@ export class MarkdownTextArea extends Component<
href={markdownHelpUrl} href={markdownHelpUrl}
class="btn btn-sm text-muted font-weight-bold" class="btn btn-sm text-muted font-weight-bold"
title={i18n.t("formatting_help")} title={i18n.t("formatting_help")}
rel="noopener" rel={relTags}
> >
<Icon icon="help-circle" classes="icon-inline" /> <Icon icon="help-circle" classes="icon-inline" />
</a> </a>

View file

@ -32,8 +32,9 @@ export class PictrsImage extends Component<PictrsImageProps, any> {
loading="lazy" loading="lazy"
className={classNames({ className={classNames({
"img-fluid": !this.props.icon && !this.props.iconOverlay, "img-fluid": !this.props.icon && !this.props.iconOverlay,
"banner": this.props.banner, banner: this.props.banner,
"thumbnail rounded": this.props.thumbnail && !this.props.icon && !this.props.banner, "thumbnail rounded":
this.props.thumbnail && !this.props.icon && !this.props.banner,
"img-expanded slight-radius": "img-expanded slight-radius":
!this.props.thumbnail && !this.props.icon, !this.props.thumbnail && !this.props.icon,
"img-blur": this.props.thumbnail && this.props.nsfw, "img-blur": this.props.thumbnail && this.props.nsfw,

View file

@ -1,7 +1,7 @@
import { Component, linkEvent } from "inferno"; import { Component, linkEvent } from "inferno";
import { SortType } from "lemmy-js-client"; import { SortType } from "lemmy-js-client";
import { i18n } from "../../i18next"; import { i18n } from "../../i18next";
import { randomStr, sortingHelpUrl } from "../../utils"; import { randomStr, relTags, sortingHelpUrl } from "../../utils";
import { Icon } from "./icon"; import { Icon } from "./icon";
interface SortSelectProps { interface SortSelectProps {
@ -71,7 +71,7 @@ export class SortSelect extends Component<SortSelectProps, SortSelectState> {
<a <a
className="text-muted" className="text-muted"
href={sortingHelpUrl} href={sortingHelpUrl}
rel="noopener" rel={relTags}
title={i18n.t("sorting_help")} title={i18n.t("sorting_help")}
> >
<Icon icon="help-circle" classes="icon-inline" /> <Icon icon="help-circle" classes="icon-inline" />

View file

@ -1,7 +1,7 @@
import { Component } from "inferno"; import { Component } from "inferno";
import { Link } from "inferno-router"; import { Link } from "inferno-router";
import { CommunitySafe } from "lemmy-js-client"; import { CommunitySafe } from "lemmy-js-client";
import { hostname, showAvatars } from "../../utils"; import { hostname, relTags, showAvatars } from "../../utils";
import { PictrsImage } from "../common/pictrs-image"; import { PictrsImage } from "../common/pictrs-image";
interface CommunityLinkProps { interface CommunityLinkProps {
@ -48,6 +48,7 @@ export class CommunityLink extends Component<CommunityLinkProps, any> {
title={apubName} title={apubName}
className={`${this.props.muted ? "text-muted" : ""}`} className={`${this.props.muted ? "text-muted" : ""}`}
href={link} href={link}
rel={relTags}
> >
{this.avatarAndName(displayName)} {this.avatarAndName(displayName)}
</a> </a>

View file

@ -38,6 +38,7 @@ import {
getPageFromProps, getPageFromProps,
getSortTypeFromProps, getSortTypeFromProps,
notifyPost, notifyPost,
relTags,
restoreScrollPosition, restoreScrollPosition,
saveCommentRes, saveCommentRes,
saveScrollPosition, saveScrollPosition,
@ -370,7 +371,7 @@ export class Community extends Component<any, State> {
<span class="mr-2"> <span class="mr-2">
<SortSelect sort={this.state.sort} onChange={this.handleSortChange} /> <SortSelect sort={this.state.sort} onChange={this.handleSortChange} />
</span> </span>
<a href={communityRss} title="RSS" rel="noopener"> <a href={communityRss} title="RSS" rel={relTags}>
<Icon icon="rss" classes="text-muted small" /> <Icon icon="rss" classes="text-muted small" />
</a> </a>
<link rel="alternate" type="application/atom+xml" href={communityRss} /> <link rel="alternate" type="application/atom+xml" href={communityRss} />

View file

@ -43,6 +43,7 @@ import {
mdToHtml, mdToHtml,
notifyPost, notifyPost,
numToSI, numToSI,
relTags,
restoreScrollPosition, restoreScrollPosition,
saveCommentRes, saveCommentRes,
saveScrollPosition, saveScrollPosition,
@ -695,7 +696,7 @@ export class Home extends Component<any, HomeState> {
</span> </span>
{this.state.listingType == ListingType.All && ( {this.state.listingType == ListingType.All && (
<> <>
<a href={allRss} rel="noopener" title="RSS"> <a href={allRss} rel={relTags} title="RSS">
<Icon icon="rss" classes="text-muted small" /> <Icon icon="rss" classes="text-muted small" />
</a> </a>
<link rel="alternate" type="application/atom+xml" href={allRss} /> <link rel="alternate" type="application/atom+xml" href={allRss} />
@ -703,7 +704,7 @@ export class Home extends Component<any, HomeState> {
)} )}
{this.state.listingType == ListingType.Local && ( {this.state.listingType == ListingType.Local && (
<> <>
<a href={localRss} rel="noopener" title="RSS"> <a href={localRss} rel={relTags} title="RSS">
<Icon icon="rss" classes="text-muted small" /> <Icon icon="rss" classes="text-muted small" />
</a> </a>
<link rel="alternate" type="application/atom+xml" href={localRss} /> <link rel="alternate" type="application/atom+xml" href={localRss} />
@ -712,7 +713,7 @@ export class Home extends Component<any, HomeState> {
{UserService.Instance.myUserInfo && {UserService.Instance.myUserInfo &&
this.state.listingType == ListingType.Subscribed && ( this.state.listingType == ListingType.Subscribed && (
<> <>
<a href={frontRss} title="RSS" rel="noopener"> <a href={frontRss} title="RSS" rel={relTags}>
<Icon icon="rss" classes="text-muted small" /> <Icon icon="rss" classes="text-muted small" />
</a> </a>
<link <link

View file

@ -1,7 +1,7 @@
import { Component } from "inferno"; import { Component } from "inferno";
import { GetSiteResponse } from "lemmy-js-client"; import { GetSiteResponse } from "lemmy-js-client";
import { i18n } from "../../i18next"; import { i18n } from "../../i18next";
import { setIsoData } from "../../utils"; import { relTags, setIsoData } from "../../utils";
import { HtmlTags } from "../common/html-tags"; import { HtmlTags } from "../common/html-tags";
interface InstancesState { interface InstancesState {
@ -60,7 +60,7 @@ export class Instances extends Component<any, InstancesState> {
<ul> <ul>
{items.map(i => ( {items.map(i => (
<li> <li>
<a href={`https://${i}`} rel="noopener"> <a href={`https://${i}`} rel={relTags}>
{i} {i}
</a> </a>
</li> </li>

View file

@ -30,6 +30,7 @@ import {
editCommentRes, editCommentRes,
fetchLimit, fetchLimit,
isBrowser, isBrowser,
relTags,
saveCommentRes, saveCommentRes,
setIsoData, setIsoData,
setupTippy, setupTippy,
@ -157,7 +158,7 @@ export class Inbox extends Component<any, InboxState> {
<h5 class="mb-2"> <h5 class="mb-2">
{i18n.t("inbox")} {i18n.t("inbox")}
<small> <small>
<a href={inboxRss} title="RSS" rel="noopener"> <a href={inboxRss} title="RSS" rel={relTags}>
<Icon icon="rss" classes="ml-2 text-muted small" /> <Icon icon="rss" classes="ml-2 text-muted small" />
</a> </a>
<link <link

View file

@ -1,7 +1,7 @@
import { Component } from "inferno"; import { Component } from "inferno";
import { Link } from "inferno-router"; import { Link } from "inferno-router";
import { PersonSafe } from "lemmy-js-client"; import { PersonSafe } from "lemmy-js-client";
import { hostname, isCakeDay, showAvatars } from "../../utils"; import { hostname, isCakeDay, relTags, showAvatars } from "../../utils";
import { PictrsImage } from "../common/pictrs-image"; import { PictrsImage } from "../common/pictrs-image";
import { CakeDay } from "./cake-day"; import { CakeDay } from "./cake-day";
@ -60,6 +60,7 @@ export class PersonListing extends Component<PersonListingProps, any> {
title={apubName} title={apubName}
className={this.props.muted ? "text-muted" : "text-info"} className={this.props.muted ? "text-muted" : "text-info"}
href={link} href={link}
rel={relTags}
> >
{this.avatarAndName(displayName)} {this.avatarAndName(displayName)}
</a> </a>

View file

@ -29,6 +29,7 @@ import {
mdToHtml, mdToHtml,
numToSI, numToSI,
previewLines, previewLines,
relTags,
restoreScrollPosition, restoreScrollPosition,
routeSortTypeToEnum, routeSortTypeToEnum,
saveCommentRes, saveCommentRes,
@ -346,7 +347,7 @@ export class Profile extends Component<any, ProfileState> {
hideHot hideHot
hideMostComments hideMostComments
/> />
<a href={profileRss} rel="noopener" title="RSS"> <a href={profileRss} rel={relTags} title="RSS">
<Icon icon="rss" classes="text-muted small mx-2" /> <Icon icon="rss" classes="text-muted small mx-2" />
</a> </a>
<link rel="alternate" type="application/atom+xml" href={profileRss} /> <link rel="alternate" type="application/atom+xml" href={profileRss} />
@ -419,7 +420,7 @@ export class Profile extends Component<any, ProfileState> {
className={`d-flex align-self-start btn btn-secondary mr-2 ${ className={`d-flex align-self-start btn btn-secondary mr-2 ${
!pv.person.matrix_user_id && "invisible" !pv.person.matrix_user_id && "invisible"
}`} }`}
rel="noopener" rel={relTags}
href={`https://matrix.to/#/${pv.person.matrix_user_id}`} href={`https://matrix.to/#/${pv.person.matrix_user_id}`}
> >
{i18n.t("send_secure_message")} {i18n.t("send_secure_message")}

View file

@ -34,6 +34,7 @@ import {
isBrowser, isBrowser,
personSelectName, personSelectName,
personToChoice, personToChoice,
relTags,
setIsoData, setIsoData,
setTheme, setTheme,
setupTippy, setupTippy,
@ -464,7 +465,7 @@ export class Settings extends Component<any, SettingsState> {
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label class="col-sm-5 col-form-label" htmlFor="matrix-user-id"> <label class="col-sm-5 col-form-label" htmlFor="matrix-user-id">
<a href={elementUrl} rel="noopener"> <a href={elementUrl} rel={relTags}>
{i18n.t("matrix_user_id")} {i18n.t("matrix_user_id")}
</a> </a>
</label> </label>

View file

@ -1,6 +1,7 @@
import { Component, linkEvent } from "inferno"; import { Component, linkEvent } from "inferno";
import { Post } from "lemmy-js-client"; import { Post } from "lemmy-js-client";
import { i18n } from "../../i18next"; import { i18n } from "../../i18next";
import { relTags } from "../../utils";
import { Icon } from "../common/icon"; import { Icon } from "../common/icon";
interface MetadataCardProps { interface MetadataCardProps {
@ -35,7 +36,7 @@ export class MetadataCard extends Component<
<div class="card-body"> <div class="card-body">
{post.name !== post.embed_title && [ {post.name !== post.embed_title && [
<h5 class="card-title d-inline"> <h5 class="card-title d-inline">
<a class="text-body" href={post.url} rel="noopener"> <a class="text-body" href={post.url} rel={relTags}>
{post.embed_title} {post.embed_title}
</a> </a>
</h5>, </h5>,
@ -43,7 +44,7 @@ export class MetadataCard extends Component<
<a <a
class="text-muted font-italic" class="text-muted font-italic"
href={post.url} href={post.url}
rel="noopener" rel={relTags}
> >
{new URL(post.url).hostname} {new URL(post.url).hostname}
<Icon icon="external-link" classes="ml-1" /> <Icon icon="external-link" classes="ml-1" />

View file

@ -33,6 +33,7 @@ import {
isBrowser, isBrowser,
isImage, isImage,
pictrsDeleteToast, pictrsDeleteToast,
relTags,
setupTippy, setupTippy,
toast, toast,
validTitle, validTitle,
@ -219,7 +220,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
this.state.postForm.url this.state.postForm.url
)}`} )}`}
class="mr-2 d-inline-block float-right text-muted small font-weight-bold" class="mr-2 d-inline-block float-right text-muted small font-weight-bold"
rel="noopener" rel={relTags}
> >
archive.org {i18n.t("archive_link")} archive.org {i18n.t("archive_link")}
</a> </a>
@ -228,7 +229,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
this.state.postForm.url this.state.postForm.url
)}`} )}`}
class="mr-2 d-inline-block float-right text-muted small font-weight-bold" class="mr-2 d-inline-block float-right text-muted small font-weight-bold"
rel="noopener" rel={relTags}
> >
ghostarchive.org {i18n.t("archive_link")} ghostarchive.org {i18n.t("archive_link")}
</a> </a>
@ -237,7 +238,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
this.state.postForm.url this.state.postForm.url
)}`} )}`}
class="mr-2 d-inline-block float-right text-muted small font-weight-bold" class="mr-2 d-inline-block float-right text-muted small font-weight-bold"
rel="noopener" rel={relTags}
> >
archive.today {i18n.t("archive_link")} archive.today {i18n.t("archive_link")}
</a> </a>

View file

@ -36,6 +36,7 @@ import {
mdToHtml, mdToHtml,
numToSI, numToSI,
previewLines, previewLines,
relTags,
setupTippy, setupTippy,
showScores, showScores,
wsClient, wsClient,
@ -244,7 +245,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
<a <a
class="text-body d-inline-block position-relative mb-2" class="text-body d-inline-block position-relative mb-2"
href={post.url} href={post.url}
rel="noopener" rel={relTags}
title={post.url} title={post.url}
> >
{this.imgThumb(this.imageSrc)} {this.imgThumb(this.imageSrc)}
@ -272,7 +273,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
className="text-body" className="text-body"
href={post.url} href={post.url}
title={post.url} title={post.url}
rel="noopener" rel={relTags}
> >
<div class="thumbnail rounded bg-light d-flex justify-content-center"> <div class="thumbnail rounded bg-light d-flex justify-content-center">
<Icon icon="external-link" classes="d-flex align-items-center" /> <Icon icon="external-link" classes="d-flex align-items-center" />
@ -335,7 +336,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
className="text-muted font-italic" className="text-muted font-italic"
href={post_view.post.url} href={post_view.post.url}
title={post_view.post.url} title={post_view.post.url}
rel="noopener" rel={relTags}
> >
{hostname(post_view.post.url)} {hostname(post_view.post.url)}
</a> </a>
@ -418,7 +419,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
className={!post.stickied ? "text-body" : "text-primary"} className={!post.stickied ? "text-body" : "text-primary"}
href={post.url} href={post.url}
title={post.url} title={post.url}
rel="noopener" rel={relTags}
> >
{post.name} {post.name}
</a> </a>

View file

@ -16,6 +16,7 @@ import {
authField, authField,
capitalizeFirstLetter, capitalizeFirstLetter,
isBrowser, isBrowser,
relTags,
setupTippy, setupTippy,
toast, toast,
wsClient, wsClient,
@ -141,7 +142,7 @@ export class PrivateMessageForm extends Component<
# #
<a <a
class="alert-link" class="alert-link"
rel="noopener" rel={relTags}
href="https://element.io/get-started" href="https://element.io/get-started"
> >
# #

View file

@ -75,6 +75,8 @@ export const postRefetchSeconds: number = 60 * 1000;
export const fetchLimit = 20; export const fetchLimit = 20;
export const mentionDropdownFetchLimit = 10; export const mentionDropdownFetchLimit = 10;
export const relTags = "noopener nofollow";
export const themes = [ export const themes = [
"litera", "litera",
"materia", "materia",