diff --git a/apps/acf-options-page/src/constants.ts b/apps/acf-options-page/src/constants.ts index 79910aab..57add2d8 100644 --- a/apps/acf-options-page/src/constants.ts +++ b/apps/acf-options-page/src/constants.ts @@ -4,8 +4,8 @@ export const APP_LINK = { BLOG: 'https://blog.getautoclicker.com/', CONFIGS: 'https://configs.getautoclicker.com/', TEST: 'https://test.getautoclicker.com/', - ISSUES: 'https://github.com/Dhruv-Techapps/acf-docs/issues', - DISCUSSIONS: 'https://github.com/Dhruv-Techapps/acf-docs/discussions', + ISSUES: 'https://github.com/Dhruv-Techapps/auto-clicker-auto-fill/issues', + DISCUSSIONS: 'https://github.com/Dhruv-Techapps/auto-clicker-auto-fill/discussions', }; // Application Languages export const APP_LANGUAGES = ['en', 'ar', 'de', 'es', 'fi', 'fr', 'id', 'it', 'ja', 'ko', 'nl', 'pt', 'ru', 'sv', 'vi', 'zh_CN']; @@ -35,7 +35,7 @@ export const SOCIAL_LINKS = { DISCORD: 'https://discord.gg/ubMBeX3', GOOGLE_GROUP: 'https://groups.google.com/g/auto-clicker-autofill', TWITTER: `https://twitter.com/intent/tweet?text=${message}&url=${url}`, - GITHUB: 'https://github.com/Dhruv-Techapps/acf-docs', + GITHUB: 'https://github.com/Dhruv-Techapps/auto-clicker-auto-fill', FACEBOOK: `https://www.facebook.com/sharer.php?u=${url}"e=${message}`, WHATSAPP: `https://wa.me/?text=${message}%5Cn%20${url}`, RATE_US: `https://chromewebstore.google.com/detail/${extensionId}/reviews`, diff --git a/apps/acf-options-page/src/store/blog/blog.api.ts b/apps/acf-options-page/src/store/blog/blog.api.ts index 791a57e8..446c7b0b 100644 --- a/apps/acf-options-page/src/store/blog/blog.api.ts +++ b/apps/acf-options-page/src/store/blog/blog.api.ts @@ -1,7 +1,7 @@ import { createAsyncThunk } from '@reduxjs/toolkit'; export const blogCheckAPI = createAsyncThunk('blog/check', async (version: string) => { - const response = await fetch(`https://api.github.com/repos/Dhruv-Techapps/acf-docs/releases/tags/v${version}`); + const response = await fetch(`https://api.github.com/repos/Dhruv-Techapps/auto-clicker-auto-fill/releases/tags/v${version}`); if (response.status === 200) { const release = await response.json(); return release; diff --git a/libs/acf/util/src/lib/value.spec.ts b/libs/acf/util/src/lib/value.spec.ts index bed6d7f3..c66cecb7 100644 --- a/libs/acf/util/src/lib/value.spec.ts +++ b/libs/acf/util/src/lib/value.spec.ts @@ -8,7 +8,6 @@ describe('getValue', () => { it('should handle RANDOM pattern correctly', async () => { const result = await Value.getValue(''); - console.log(result); expect(result).toMatch(/[a-zA-Z]{5}/); }); @@ -35,4 +34,30 @@ describe('getValue', () => { const result = await Value.getValue(''); expect(result).toBe('10'); }); + + it('should handle multiple QUERY patterns correctly', async () => { + const searchParams = new URLSearchParams(); + searchParams.set('param1', 'value1'); + searchParams.set('param2', 'value2'); + const originalSearch = window.location.search; + window.history.replaceState({}, '', `${window.location.pathname}?${searchParams.toString()}`); + + const result = await Value.getValue(' and '); + expect(result).toBe('value1 and value2'); + + window.history.replaceState({}, '', `${window.location.pathname}${originalSearch}`); + }); + + it('should handle multiple QUERY patterns correctly with sanitization and validation', async () => { + const searchParams = new URLSearchParams(); + searchParams.set('param1', 'value1'); + searchParams.set('param2', 'value2'); + const originalSearch = window.location.search; + window.history.replaceState({}, '', `${window.location.pathname}?${searchParams.toString()}`); + + const result = await Value.getValue(' and '); + expect(result).toBe('value1 and param2'); + + window.history.replaceState({}, '', `${window.location.pathname}${originalSearch}`); + }); }); diff --git a/libs/acf/util/src/lib/value.ts b/libs/acf/util/src/lib/value.ts index c0b6fc1c..b929e68f 100644 --- a/libs/acf/util/src/lib/value.ts +++ b/libs/acf/util/src/lib/value.ts @@ -13,6 +13,7 @@ declare global { export const VALUE_MATCHER = { QUERY_PARAM: /^Query::/i, + QUERY: //gi, API: /^Api::/i, RANDOM: //gi, BATCH_REPEAT: //, @@ -38,15 +39,41 @@ export const Value = (() => { const getSessionCount = (value: string) => value.replaceAll('', String(window.__sessionCount)); + const sanitizeInput = (input: string): string => { + const element = document.createElement('div'); + element.textContent = input; + return element.innerHTML; + }; + + const validateQueryParam = (key: string, value: string): boolean => { + const pattern = /^[a-zA-Z0-9_-]+$/; + return pattern.test(key) && pattern.test(value); + }; + const getQueryParam = (value: string) => { - const [, key] = value.split('::'); const searchParams = new URLSearchParams(window.location.search); + const [, key] = value.split('::'); if (searchParams.has(key)) { - value = searchParams.get(key) || key; + const paramValue = searchParams.get(key) ?? key; + if (validateQueryParam(key, paramValue)) { + value = sanitizeInput(paramValue); + } } return value; }; + const getMultiQueryParam = (value: string) => { + const searchParams = new URLSearchParams(window.location.search); + value = value.replace(VALUE_MATCHER.QUERY, (_, key) => { + const paramValue = searchParams.get(key) ?? key; + if (validateQueryParam(key, paramValue)) { + return sanitizeInput(paramValue); + } + return key; + }); + return value; + }; + const getApiValue = (value: string): string => { const [, key] = value.split('::'); const apiValue = window.__api?.[key]; @@ -76,6 +103,9 @@ export const Value = (() => { if (VALUE_MATCHER.QUERY_PARAM.test(value)) { value = getQueryParam(value); } + if (VALUE_MATCHER.QUERY.test(value)) { + value = getMultiQueryParam(value); + } if (VALUE_MATCHER.BATCH_REPEAT.test(value)) { value = getBatchRepeat(value); } diff --git a/libs/ui/src/constants.ts b/libs/ui/src/constants.ts index ef92a145..9b5c82d1 100644 --- a/libs/ui/src/constants.ts +++ b/libs/ui/src/constants.ts @@ -4,8 +4,8 @@ export const APP_LINK = { BLOG: 'https://blog.getautoclicker.com/', CONFIGS: 'https://gist.github.com/dharmesh-hemaram', TEST: 'https://test.getautoclicker.com/', - ISSUES: 'https://github.com/Dhruv-Techapps/acf-docs/issues', - DISCUSSIONS: 'https://github.com/Dhruv-Techapps/acf-docs/discussions', + ISSUES: 'https://github.com/Dhruv-Techapps/auto-clicker-auto-fill/issues', + DISCUSSIONS: 'https://github.com/Dhruv-Techapps/auto-clicker-auto-fill/discussions', }; // Application Languages export const APP_LANGUAGES = ['en', 'ar', 'de', 'es', 'fi', 'fr', 'id', 'it', 'ja', 'ko', 'nl', 'pt', 'ru', 'sv', 'vi', 'zh_CN']; @@ -35,7 +35,7 @@ export const SOCIAL_LINKS = { DISCORD: 'https://discord.gg/ubMBeX3', GOOGLE_GROUP: 'https://groups.google.com/g/auto-clicker-autofill', TWITTER: `https://twitter.com/intent/tweet?text=${message}&url=${url}`, - GITHUB: 'https://github.com/Dhruv-Techapps/acf-docs', + GITHUB: 'https://github.com/Dhruv-Techapps/auto-clicker-auto-fill', FACEBOOK: `https://www.facebook.com/sharer.php?u=${url}"e=${message}`, WHATSAPP: `https://wa.me/?text=${message}%5Cn%20${url}`, RATE_US: `https://chromewebstore.google.com/detail/${extensionId}/reviews`,