Skip to content

Conversation

@rfc2822
Copy link
Member

@rfc2822 rfc2822 commented Jan 16, 2026

Purpose

Fix URL parsing in toUrlOrNull() and related methods to properly catch URLDecodeException when parsing invalid URLs, ensuring consistent behavior with Ktor's parseUrl function.

Short description

  • Changed exception handling from URLParserException to Exception in toUrlOrNull() method in KtorHttpUtils.kt
  • Updated exception handling in DavResource.kt and ResponseParser.kt to catch broader exceptions
  • Added test case for invalid HTTPS URL that can't be decoded (https://example.com/%f)
  • Added documentation comment explaining the difference from Ktor's parseUrl and referencing the Ktor issue

- Update `toUrlOrNull` method to catch all exceptions
- Add test case for invalid HTTPS URL with decoding issues
@rfc2822 rfc2822 linked an issue Jan 16, 2026 that may be closed by this pull request
3 tasks
@rfc2822 rfc2822 self-assigned this Jan 16, 2026
@rfc2822 rfc2822 added the bug Something isn't working label Jan 16, 2026
@rfc2822 rfc2822 marked this pull request as ready for review January 16, 2026 14:16
@rfc2822 rfc2822 merged commit acf8e4e into main Jan 16, 2026
5 checks passed
@rfc2822 rfc2822 deleted the 148-ktor-methods-like-ktorhttputilskttourlornull-dont-catch-urldecodeexception branch January 16, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Ktor] Methods like KtorHttpUtilsKt.toUrlOrNull don't catch URLDecodeException

1 participant