Skip to content

Commit

Permalink
chore(link) ensure noopener is set on all outgoing links
Browse files Browse the repository at this point in the history
Signed-off-by: David Edler <david.edler@canonical.com>
  • Loading branch information
edlerd committed Mar 1, 2024
1 parent 7609084 commit d45a24c
Show file tree
Hide file tree
Showing 18 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/components/HelpLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const HelpLink: FC<Props> = ({ children, href, title }) => {
return (
<div className="help-link">
{children}
<a href={href} target="_blank" rel="noreferrer" title={title}>
<a href={href} target="_blank" rel="noopener noreferrer" title={title}>
<Icon name="info--dark" className="help-link-icon" />
</a>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ const Navigation: FC = () => {
className="p-side-navigation__link"
href={docBaseLink}
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
title="Documentation"
>
<Icon
Expand All @@ -286,7 +286,7 @@ const Navigation: FC = () => {
className="p-side-navigation__link"
href="https://discourse.ubuntu.com/c/lxd/126"
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
title="Discussion"
>
<Icon
Expand All @@ -301,7 +301,7 @@ const Navigation: FC = () => {
className="p-side-navigation__link"
href="https://github.com/canonical/lxd-ui/issues/new"
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
title="Report a bug"
>
<Icon
Expand Down
2 changes: 1 addition & 1 deletion src/components/NoMatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const NoMatch: FC = () => {
<a
href="https://github.com/canonical/lxd-ui/issues/new"
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
title="Report a bug"
>
Report a bug
Expand Down
4 changes: 2 additions & 2 deletions src/pages/cluster/ClusterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const ClusterList: FC = () => {
<a
href={`${docBaseLink}/explanation/clustering/`}
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
>
Learn more about clustering
<Icon className="external-link-icon" name="external-link" />
Expand All @@ -147,7 +147,7 @@ const ClusterList: FC = () => {
<a
href={`${docBaseLink}/explanation/clustering/`}
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
>
Learn more about clustering
<Icon className="external-link-icon" name="external-link" />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/instances/InstanceList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ const InstanceList: FC = () => {
<a
href={`${docBaseLink}/howto/instances_create/`}
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
>
How to create instances
<Icon className="external-link-icon" name="external-link" />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/instances/InstanceSnapshots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ const InstanceSnapshots = (props: Props) => {
<a
href={`${docBaseLink}/howto/storage_backup_volume/#storage-backup-snapshots`}
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
>
Learn more about snapshots
<Icon className="external-link-icon" name="external-link" />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/networks/NetworkForwards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const NetworkForwards: FC<Props> = ({ network, project }) => {
<a
href={`${docBaseLink}/howto/network_forwards/`}
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
>
Learn more about network forwards
<Icon className="external-link-icon" name="external-link" />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/networks/NetworkList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const NetworkList: FC = () => {
<a
href={`${docBaseLink}/explanation/networks/`}
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
>
Learn more about networks
<Icon className="external-link-icon" name="external-link" />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/networks/forms/NetworkTypeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const NetworkTypeSelector: FC<Props> = ({ formik }) => {
<a
href={`${docBaseLink}/howto/network_ovn_setup/#set-up-a-lxd-cluster-on-ovn`}
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
>
Learn how to set up OVN
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/storage/CustomIsoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const CustomIsoList: FC<Props> = ({ project }) => {
<a
href={`${docBaseLink}/explanation/storage/`}
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
>
Learn more about storage
<Icon className="external-link-icon" name="external-link" />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/storage/StoragePools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const StoragePools: FC = () => {
<a
href={`${docBaseLink}/explanation/storage/`}
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
>
Learn more about storage
<Icon className="external-link-icon" name="external-link" />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/storage/StorageVolumeSnapshots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ const StorageVolumeSnapshots: FC<Props> = ({ volume }) => {
<a
href={`${docBaseLink}/howto/storage_backup_volume/#storage-backup-snapshots`}
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
>
Learn more about snapshots
<Icon className="external-link-icon" name="external-link" />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/storage/StorageVolumes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ const StorageVolumes: FC = () => {
<a
href={`${docBaseLink}/explanation/storage/`}
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
>
Learn more about storage
<Icon className="external-link-icon" name="external-link" />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/storage/UploadCustomImageHint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const UploadCustomImageHint: FC = () => {
className="p-notification__action"
href="https://ubuntu.com/tutorials/how-to-install-a-windows-11-vm-using-lxd#1-overview"
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
>
Windows ISO images
<Icon className="external-link-icon" name="external-link" />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/storage/forms/StorageVolumeFormBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const StorageVolumeFormBlock: FC<Props> = ({ formik }) => {
For a list of available options visit{" "}
<a
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
href="https://manpages.ubuntu.com/manpages/jammy/en/man8/mount.8.html#filesystem-independent%20mount%20options"
>
mount manpages
Expand Down
2 changes: 1 addition & 1 deletion src/pages/storage/forms/StorageVolumeFormSnapshots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const StorageVolumeFormSnapshots: FC<Props> = ({ formik }) => {
<a
href={`${docBaseLink}/reference/instance_options/#instance-options-snapshots-names`}
target="_blank"
rel="noreferrer"
rel="noopener noreferrer"
>
Automatic snapshot names
</a>
Expand Down
4 changes: 2 additions & 2 deletions src/util/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe("toConfigFields and replaceDocLinks", () => {
);

expect(result).toBe(
'Specify a Pongo2 template string that represents the snapshot name.<br>This template is used for scheduled snapshots and for unnamed snapshots.<br><br>See <a href="https://docs.example.org/reference/instance_options/#instance-options-snapshots-names" target="_blank" rel="noreferrer">instance options snapshots names</a> for more information.',
'Specify a Pongo2 template string that represents the snapshot name.<br>This template is used for scheduled snapshots and for unnamed snapshots.<br><br>See <a href="https://docs.example.org/reference/instance_options/#instance-options-snapshots-names" target="_blank" rel="noopener noreferrer">instance options snapshots names</a> for more information.',
);
});

Expand All @@ -96,7 +96,7 @@ describe("toConfigFields and replaceDocLinks", () => {
);

expect(result).toBe(
'the value of <a href="https://docs.example.org/reference/storage_zfs/#storage-zfs-volume-conf:zfs.block_mode" target="_blank" rel="noreferrer">zfs.block_mode</a>,<br>the specified',
'the value of <a href="https://docs.example.org/reference/storage_zfs/#storage-zfs-volume-conf:zfs.block_mode" target="_blank" rel="noopener noreferrer">zfs.block_mode</a>,<br>the specified',
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/util/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const configDescriptionToHtml = (
}
const docPath = line.split(": ")[1];
const linkText = token.replaceAll("-", " ");
const link = `<a href="${docBaseLink}/${docPath}" target="_blank" rel="noreferrer">${linkText}</a>`;
const link = `<a href="${docBaseLink}/${docPath}" target="_blank" rel="noopener noreferrer">${linkText}</a>`;

result = result.replaceAll(tag, link);
});
Expand Down

0 comments on commit d45a24c

Please sign in to comment.