From 2abc2b13f0bcfd715d4552e94b0906dceb1f2794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Wed, 30 Oct 2024 22:47:17 +0100 Subject: [PATCH 1/3] wrap encodeURI in try catch --- client/homebrew/pages/editPage/editPage.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index 744e187a6d..de71f02a03 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -380,7 +380,15 @@ const EditPage = createClass({ **[Homebrewery Link](${global.config.publicUrl}/share/${shareLink})**`; - return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodeURIComponent(title)}&text=${encodeURIComponent(text)}`; + let encodedTitle; + try { + encodedTitle = encodeURIComponent(title); + } catch (error) { + console.error("Error encoding title for Reddit link:", error); + encodedTitle = encodeURIComponent("Check out my homebrew!"); // Fallback title + } + + return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodedTitle}&text=${encodeURIComponent(text)}`; }, renderNavbar : function(){ From 56f348f7ed7dbb9df98e26a38fa5f114647b5c7e Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sun, 15 Dec 2024 23:44:56 -0500 Subject: [PATCH 2/3] Replace with `toWellFormed()` --- client/homebrew/pages/editPage/editPage.jsx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index de71f02a03..e5f6d909cf 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -380,15 +380,7 @@ const EditPage = createClass({ **[Homebrewery Link](${global.config.publicUrl}/share/${shareLink})**`; - let encodedTitle; - try { - encodedTitle = encodeURIComponent(title); - } catch (error) { - console.error("Error encoding title for Reddit link:", error); - encodedTitle = encodeURIComponent("Check out my homebrew!"); // Fallback title - } - - return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodedTitle}&text=${encodeURIComponent(text)}`; +return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodeURIComponent(title.toWellFormed())}&text=${encodeURIComponent(text)}`; }, renderNavbar : function(){ From cb16b320167fab3a50446d32855368d120917916 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sun, 15 Dec 2024 23:45:54 -0500 Subject: [PATCH 3/3] tabs --- client/homebrew/pages/editPage/editPage.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/homebrew/pages/editPage/editPage.jsx b/client/homebrew/pages/editPage/editPage.jsx index e5f6d909cf..865c4ce2ae 100644 --- a/client/homebrew/pages/editPage/editPage.jsx +++ b/client/homebrew/pages/editPage/editPage.jsx @@ -380,7 +380,7 @@ const EditPage = createClass({ **[Homebrewery Link](${global.config.publicUrl}/share/${shareLink})**`; -return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodeURIComponent(title.toWellFormed())}&text=${encodeURIComponent(text)}`; + return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodeURIComponent(title.toWellFormed())}&text=${encodeURIComponent(text)}`; }, renderNavbar : function(){