diff --git a/browser-extensions/chrome/src/app/pages/EmailDetails.tsx b/browser-extensions/chrome/src/app/pages/EmailDetails.tsx
index 2f80d78c4..5448c33e4 100644
--- a/browser-extensions/chrome/src/app/pages/EmailDetails.tsx
+++ b/browser-extensions/chrome/src/app/pages/EmailDetails.tsx
@@ -8,6 +8,7 @@ import { useMinDurationLoading } from '../hooks/useMinDurationLoading';
import EncryptionUtility from '../../shared/EncryptionUtility';
import { Attachment } from '../../shared/types/webapi/Attachment';
import { useLoading } from '../context/LoadingContext';
+import ConversionUtility from '../utils/ConversionUtility';
/**
* Email details page.
@@ -227,7 +228,7 @@ const EmailDetails: React.FC = () => {
{email.messageHtml ? (
diff --git a/browser-extensions/chrome/src/app/utils/ConversionUtility.tsx b/browser-extensions/chrome/src/app/utils/ConversionUtility.tsx
new file mode 100644
index 000000000..9aeeffe52
--- /dev/null
+++ b/browser-extensions/chrome/src/app/utils/ConversionUtility.tsx
@@ -0,0 +1,56 @@
+/**
+ * Utility class for conversion operations.
+ */
+class ConversionUtility {
+ /**
+ * Convert all anchor tags to open in a new tab.
+ * @param html HTML input.
+ * @returns HTML with all anchor tags converted to open in a new tab when clicked on.
+ *
+ * Note: same implementation exists in c-sharp version in AliasVault.Shared.Utilities.ConversionUtility.cs
+ */
+ public convertAnchorTagsToOpenInNewTab(html: string): string {
+ try {
+ // Create a DOM parser
+ const parser = new DOMParser();
+ const doc = parser.parseFromString(html, 'text/html');
+
+ // Select all anchor tags with href attribute
+ const anchors = doc.querySelectorAll('a[href]');
+
+ if (anchors.length > 0) {
+ anchors.forEach((anchor: Element) => {
+ // Handle target attribute
+ if (!anchor.hasAttribute('target')) {
+ anchor.setAttribute('target', '_blank');
+ } else if (anchor.getAttribute('target') !== '_blank') {
+ anchor.setAttribute('target', '_blank');
+ }
+
+ // Handle rel attribute for security
+ if (!anchor.hasAttribute('rel')) {
+ anchor.setAttribute('rel', 'noopener noreferrer');
+ } else {
+ const relValue = anchor.getAttribute('rel') ?? '';
+ const relValues = new Set(relValue.split(' ').filter(val => val.trim() !== ''));
+
+ relValues.add('noopener');
+ relValues.add('noreferrer');
+
+ anchor.setAttribute('rel', Array.from(relValues).join(' '));
+ }
+ });
+ }
+
+ return doc.documentElement.outerHTML;
+ } catch (ex) {
+ // Log the exception
+ console.error(`Error in convertAnchorTagsToOpenInNewTab: ${ex instanceof Error ? ex.message : String(ex)}`);
+
+ // Return the original HTML if an error occurs
+ return html;
+ }
+ }
+}
+
+export default new ConversionUtility();
diff --git a/src/Shared/AliasVault.Shared/Utilities/ConversionUtility.cs b/src/Shared/AliasVault.Shared/Utilities/ConversionUtility.cs
index cb539b2df..e6b4de487 100644
--- a/src/Shared/AliasVault.Shared/Utilities/ConversionUtility.cs
+++ b/src/Shared/AliasVault.Shared/Utilities/ConversionUtility.cs
@@ -19,6 +19,9 @@ public static class ConversionUtility
///
///
HTML input.
///
HTML with all anchor tags converted to open in a new tab when clicked on.
+ ///
+ /// Note: same implementation exists in browser extension Typescript version in ConversionUtility.ts.
+ ///
public static string ConvertAnchorTagsToOpenInNewTab(string html)
{
try