From 95e0274384928a4d781f8a24729a94a8615e23b2 Mon Sep 17 00:00:00 2001 From: Cas_ <6506529+ThaUnknown@users.noreply.github.com> Date: Thu, 5 Sep 2024 19:56:19 +0200 Subject: [PATCH 1/5] chore: Create CONTRIBUTING.md --- CONTRIBUTING.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..3fe4ffc --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,25 @@ +``` +By making a contribution to this project, I certify that: + + (a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + + (b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + + (c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + + (d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. +``` From 8f286e1fbe4d645c24d6760b1932d5812838b2e1 Mon Sep 17 00:00:00 2001 From: jubiman Date: Mon, 9 Sep 2024 23:02:01 +0200 Subject: [PATCH 2/5] Fix line feed at the end of state returned from MAL and undefined symbol 'line' in linux's clipboard paste handler --- common/modules/settings.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/modules/settings.js b/common/modules/settings.js index 2c6caee..da82485 100644 --- a/common/modules/settings.js +++ b/common/modules/settings.js @@ -55,13 +55,13 @@ window.addEventListener('paste', ({ clipboardData }) => { clipboardData.items[0].getAsString(text => { if (text.includes("access_token=")) { // is an AniList token let token = text.split('access_token=')?.[1]?.split('&token_type')?.[0] - if (token) { + if (token) {state if (token.endsWith('/')) token = token.slice(0, -1) handleToken(token) } } else if (text.includes("code=") && text.includes("&state")) { // is a MyAnimeList authorization - let code = line.split('code=')[1].split('&state')[0] - let state = line.split('&state=')[1] + let code = text.split('code=')[1].split('&state')[0] + let state = text.split('&state=')[1] if (code && state) { if (code.endsWith('/')) code = code.slice(0, -1) if (state.endsWith('/')) state = state.slice(0, -1) @@ -98,6 +98,8 @@ async function handleMalToken (code, state) { debug(`Failed to get the state and code from MyAnimeList.`) return } + // remove linefeed characters from the state + state = state.replace(/(\r\n|\n|\r)/gm, '') const response = await fetch('https://myanimelist.net/v1/oauth2/token', { method: 'POST', headers: { From 0277b171e0f27e1effd9dafebabb10f3c53aca63 Mon Sep 17 00:00:00 2001 From: jubiman Date: Mon, 9 Sep 2024 23:03:42 +0200 Subject: [PATCH 3/5] fix trailing 'state' on line 58 I don't know how it got there --- common/modules/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/modules/settings.js b/common/modules/settings.js index da82485..8ac8145 100644 --- a/common/modules/settings.js +++ b/common/modules/settings.js @@ -55,7 +55,7 @@ window.addEventListener('paste', ({ clipboardData }) => { clipboardData.items[0].getAsString(text => { if (text.includes("access_token=")) { // is an AniList token let token = text.split('access_token=')?.[1]?.split('&token_type')?.[0] - if (token) {state + if (token) { if (token.endsWith('/')) token = token.slice(0, -1) handleToken(token) } From f165ba84691dad0614c9caf6f5d59a7e0ec022ab Mon Sep 17 00:00:00 2001 From: jubiman Date: Mon, 9 Sep 2024 23:05:40 +0200 Subject: [PATCH 4/5] Replace the line that removes the linefeed to somewhere that makes more sense --- common/modules/settings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/modules/settings.js b/common/modules/settings.js index 8ac8145..70bb3e1 100644 --- a/common/modules/settings.js +++ b/common/modules/settings.js @@ -66,6 +66,8 @@ window.addEventListener('paste', ({ clipboardData }) => { if (code.endsWith('/')) code = code.slice(0, -1) if (state.endsWith('/')) state = state.slice(0, -1) if (state.includes('%')) state = decodeURIComponent(state) + // remove linefeed characters from the state + state = state.replace(/(\r\n|\n|\r)/gm, '') handleMalToken(code, state) } } @@ -98,8 +100,6 @@ async function handleMalToken (code, state) { debug(`Failed to get the state and code from MyAnimeList.`) return } - // remove linefeed characters from the state - state = state.replace(/(\r\n|\n|\r)/gm, '') const response = await fetch('https://myanimelist.net/v1/oauth2/token', { method: 'POST', headers: { From 1ff02a60c45e7074dc5014ef3da0cf6ff52ae9e0 Mon Sep 17 00:00:00 2001 From: Jason Watanabe Date: Mon, 9 Sep 2024 16:15:16 -0700 Subject: [PATCH 5/5] fix: code linefeed --- common/modules/settings.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/modules/settings.js b/common/modules/settings.js index 70bb3e1..e55a986 100644 --- a/common/modules/settings.js +++ b/common/modules/settings.js @@ -4,7 +4,7 @@ import IPC from '@/modules/ipc.js' import { toast } from 'svelte-sonner' import Debug from 'debug' -const debug = Debug('ui:anilist') +const debug = Debug('ui:settings') export let profiles = writable(JSON.parse(localStorage.getItem('profiles')) || []) /** @type {{viewer: import('./al').Query<{Viewer: import('./al').Viewer}>, token: string} | null} */ @@ -67,6 +67,7 @@ window.addEventListener('paste', ({ clipboardData }) => { if (state.endsWith('/')) state = state.slice(0, -1) if (state.includes('%')) state = decodeURIComponent(state) // remove linefeed characters from the state + code = code.replace(/(\r\n|\n|\r)/gm, '') state = state.replace(/(\r\n|\n|\r)/gm, '') handleMalToken(code, state) }