Files
dify/web/utils/urlValidation.spec.ts
+22
longbingljwGitHubgemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>crazywoolaautofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>Copilotgemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>Asuka Minato-LAN-autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>aka James4uNoviceyangzheliElliottjohnny0120gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>Gritty_devgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>wangjifengautofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>Boris PolonskyYongtao HuangCursxJyongred_sunNFishQuantumGhosthj24kenwoodjw
36e6205c6c feat:update latest commit (#51)
* test: adding some web tests (#27792)

* feat: add validation to prevent saving empty opening statement in conversation opener modal (#27843)

* fix(web): improve the consistency of the inputs-form UI (#27837)

* fix(web): increase z-index of PortalToFollowElemContent (#27823)

* fix: installation_id is missing when in tools page (#27849)

* fix: avoid passing empty uniqueIdentifier to InstallFromMarketplace (#27802)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* test: create new test scripts and update some existing test scripts o… (#27850)

* feat: change feedback to forum (#27862)

* chore: translate i18n files and update type definitions (#27868)

Co-authored-by: crazywoola <[email protected]>

* Fix/template transformer line number (#27867)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: crazywoola <[email protected]>

* bump vite to 6.4.1 (#27877)

* Add WEAVIATE_GRPC_ENDPOINT as designed in weaviate migration guide (#27861)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* Fix: correct DraftWorkflowApi.post response model (#27289)

Signed-off-by: Yongtao Huang <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

* fix Version 2.0.0-beta.2: Chat annotations Api Error #25506  (#27206)

Co-authored-by: crazywoola <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Asuka Minato <[email protected]>

* fix jina reader creadential migration command (#27883)

* fix agent putout the output of workflow-tool twice (#26835) (#27087)

* fix jina reader transform (#27922)

* fix: prevent fetch version info in enterprise edition (#27923)

* fix(api): fix `VariablePool.get` adding unexpected keys to variable_dictionary (#26767)

Co-authored-by: -LAN- <[email protected]>
Co-authored-by: Copilot <[email protected]>

* refactor: implement tenant self queue for rag tasks (#27559)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: -LAN- <[email protected]>

* fix: bump brotli to 1.2.0 resloved CVE-2025-6176 (#27950)

Signed-off-by: kenwoodjw <[email protected]>

---------

Signed-off-by: Yongtao Huang <[email protected]>
Signed-off-by: kenwoodjw <[email protected]>
Co-authored-by: aka James4u <[email protected]>
Co-authored-by: Novice <[email protected]>
Co-authored-by: yangzheli <[email protected]>
Co-authored-by: Elliott <[email protected]>
Co-authored-by: crazywoola <[email protected]>
Co-authored-by: johnny0120 <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Gritty_dev <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: wangjifeng <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Boris Polonsky <[email protected]>
Co-authored-by: Yongtao Huang <[email protected]>
Co-authored-by: Cursx <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Asuka Minato <[email protected]>
Co-authored-by: Jyong <[email protected]>
Co-authored-by: red_sun <[email protected]>
Co-authored-by: NFish <[email protected]>
Co-authored-by: QuantumGhost <[email protected]>
Co-authored-by: -LAN- <[email protected]>
Co-authored-by: hj24 <[email protected]>
Co-authored-by: kenwoodjw <[email protected]>
2025-11-07 17:25:58 +08:00

50 lines
2.0 KiB
TypeScript

import { validateRedirectUrl } from './urlValidation'
describe('URL Validation', () => {
describe('validateRedirectUrl', () => {
it('should reject data: protocol', () => {
expect(() => validateRedirectUrl('data:text/html,<script>alert(1)</script>')).toThrow('Authorization URL must be HTTP or HTTPS')
})
it('should reject file: protocol', () => {
expect(() => validateRedirectUrl('file:///etc/passwd')).toThrow('Authorization URL must be HTTP or HTTPS')
})
it('should reject ftp: protocol', () => {
expect(() => validateRedirectUrl('ftp://example.com')).toThrow('Authorization URL must be HTTP or HTTPS')
})
it('should reject vbscript: protocol', () => {
expect(() => validateRedirectUrl('vbscript:msgbox(1)')).toThrow('Authorization URL must be HTTP or HTTPS')
})
it('should reject malformed URLs', () => {
expect(() => validateRedirectUrl('not a url')).toThrow('Invalid URL')
expect(() => validateRedirectUrl('://example.com')).toThrow('Invalid URL')
expect(() => validateRedirectUrl('')).toThrow('Invalid URL')
})
it('should handle URLs with query parameters', () => {
expect(() => validateRedirectUrl('https://example.com?param=value')).not.toThrow()
expect(() => validateRedirectUrl('https://example.com?redirect=http://evil.com')).not.toThrow()
})
it('should handle URLs with fragments', () => {
expect(() => validateRedirectUrl('https://example.com#section')).not.toThrow()
expect(() => validateRedirectUrl('https://example.com/path#fragment')).not.toThrow()
})
it('should handle URLs with authentication', () => {
expect(() => validateRedirectUrl('https://user:[email protected]')).not.toThrow()
})
it('should handle international domain names', () => {
expect(() => validateRedirectUrl('https://例え.jp')).not.toThrow()
})
it('should reject protocol-relative URLs', () => {
expect(() => validateRedirectUrl('//example.com')).toThrow('Invalid URL')
})
})
})