fix: strip port from pasted URLs, sanitize RNode/UDP hosts#538
Merged
torlando-tech merged 3 commits intorelease/v0.8.xfrom Feb 24, 2026
Merged
fix: strip port from pasted URLs, sanitize RNode/UDP hosts#538torlando-tech merged 3 commits intorelease/v0.8.xfrom
torlando-tech merged 3 commits intorelease/v0.8.xfrom
Conversation
…vel stripping Address Greptile review feedback on #533: - Strip trailing :port from hostnames (e.g. "example.com:8080" → "example.com") - Use cleaned values from validateHostname() in RNode TCP and UDP entityToConfig branches - Strip http:// and https:// in UI text field onValueChange handlers for immediate feedback Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Greptile SummaryAddresses Greptile review feedback from #533 by implementing a safer port-stripping strategy using colon count rather than regex matching. The PR correctly fixes the previously identified IPv6 corruption issue by checking if a string has exactly one colon before applying port stripping logic. Key improvements:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 0db9d43 |
app/src/main/java/com/lxmf/messenger/util/validation/InputValidator.kt
Outdated
Show resolved
Hide resolved
Add IPV6_REGEX check before port-stripping to prevent corrupting IPv6 addresses like "2001:db8::1" where the trailing ":1" looks like a port number. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
Author
app/src/main/java/com/lxmf/messenger/util/validation/InputValidator.kt
Outdated
Show resolved
Hide resolved
Comment on lines
+289
to
+297
| fun `validateHostname - does not strip segments from IPv6 address`() { | ||
| // IPv6 like "2001:db8::1" ends with ":1" which could look like a port | ||
| val validIPv6 = listOf("2001:db8:85a3:0:0:8a2e:370:7334", "fe80:0:0:0:0:0:0:1") | ||
| validIPv6.forEach { ipv6 -> | ||
| val result = InputValidator.validateHostname(ipv6) | ||
| assertTrue("$ipv6 should be valid", result is ValidationResult.Success) | ||
| assertEquals(ipv6, result.getOrNull()) | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Missing test for ::1 and other compressed IPv6 forms
Test only covers full/uncompressed IPv6. Missing critical cases:
::1(loopback)fe80::1(link-local)::ffff:192.0.2.1(IPv4-mapped)
These would fail with current implementation due to incomplete IPV6_REGEX.
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/src/test/java/com/lxmf/messenger/util/validation/InputValidatorTest.kt
Line: 289-297
Comment:
Missing test for `::1` and other compressed IPv6 forms
Test only covers full/uncompressed IPv6. Missing critical cases:
- `::1` (loopback)
- `fe80::1` (link-local)
- `::ffff:192.0.2.1` (IPv4-mapped)
These would fail with current implementation due to incomplete `IPV6_REGEX`.
How can I resolve this? If you propose a fix, please make it concise.
Owner
Author
Compressed IPv6 like "::1" or "fe80::1" aren't matched by IPV6_REGEX and would be corrupted by port stripping. Instead of fixing the regex, use a simpler invariant: IPv6 always has multiple colons, hostname:port has exactly one. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3 tasks
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #533, addressing Greptile review feedback:
:portfrom hostnames (e.g.http://example.com:8080→example.com)validateHostname()in RNode TCP and UDPentityToConfig()branches (previously discarded)http://andhttps://in UI text fieldonValueChangehandlers for immediate visual feedbackTest plan
http://example.com:8080in TCP host field, verify it becomesexample.com🤖 Generated with Claude Code