Skip to content

fix: strip URI scheme prefixes from hostname input#532

Merged
torlando-tech merged 1 commit intomainfrom
fix/strip-hostname-uri-scheme
Feb 23, 2026
Merged

fix: strip URI scheme prefixes from hostname input#532
torlando-tech merged 1 commit intomainfrom
fix/strip-hostname-uri-scheme

Conversation

@torlando-tech
Copy link
Copy Markdown
Owner

Summary

  • validateHostname() now strips http:// and https:// prefixes (and any path component) before validation, so users who paste a full URL get the hostname extracted automatically
  • entityToConfig() uses the cleaned value from validation, fixing existing poison data in the database on read
  • validateConfigState() writes the cleaned hostname back to UI state so subsequent saves persist the sanitized value

Context

Fixes COLUMBA-43 — users entering http://rns.soon.it as a TCP host caused a fatal IllegalStateException when editing the interface config. 5 occurrences across 2 users on v0.8.12-beta.

Test plan

  • 5 new unit tests for scheme stripping (http, https, trailing slash, path, IP)
  • All existing InputValidatorTest, InterfaceRepositoryTest, and InterfaceManagementViewModelTest pass
  • Manual: enter http://rns.soon.it as TCP host, verify it saves as rns.soon.it
  • Manual: edit an existing interface with a scheme-prefixed host in the DB, verify no crash

🤖 Generated with Claude Code

Users pasting URLs like "http://rns.soon.it" instead of bare hostnames
caused a fatal IllegalStateException when editing the interface config.
validateHostname() now strips http:// and https:// prefixes, and callers
use the cleaned value instead of the raw input.

Fixes COLUMBA-43

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 23, 2026

Greptile Summary

This PR fixes a fatal crash (COLUMBA-43) when users paste full URLs like http://rns.soon.it instead of bare hostnames in TCP interface configuration.

Changes Made:

  • validateHostname() now strips http://, https://, trailing slashes, and path components before validation
  • entityToConfig() uses the cleaned value from validation to sanitize poisoned database records on read
  • validateConfigState() writes cleaned hostnames back to UI state so subsequent saves persist the sanitized value
  • 5 comprehensive unit tests added for scheme stripping scenarios

Impact:

  • Prevents IllegalStateException crashes when editing interfaces with scheme-prefixed hostnames
  • Automatically fixes existing bad data in the database when interfaces are loaded
  • Improves UX by accepting URLs users commonly copy from browsers

Confidence Score: 5/5

  • Safe to merge - focused bug fix with comprehensive testing and backward-compatible sanitization
  • The implementation is sound: hostname validation logic correctly strips URI schemes, database read layer sanitizes poisoned data, UI state management persists cleaned values, and 5 new unit tests provide excellent coverage. No breaking changes or edge cases identified.
  • No files require special attention

Important Files Changed

Filename Overview
app/src/main/java/com/lxmf/messenger/util/validation/InputValidator.kt Added URI scheme stripping (http://, https://) and path removal to validateHostname(), plus formatting changes to expression bodies
app/src/main/java/com/lxmf/messenger/repository/InterfaceRepository.kt Modified entityToConfig() to use cleaned hostname values from validation for TCPClient and TCPServer, fixing poisoned data on read
app/src/main/java/com/lxmf/messenger/viewmodel/InterfaceManagementViewModel.kt Updated validateConfigState() to write back cleaned hostnames to UI state, ensuring sanitized values persist on save
app/src/test/java/com/lxmf/messenger/util/validation/InputValidatorTest.kt Added 5 comprehensive tests for URI scheme stripping covering http, https, trailing slashes, paths, and IP addresses

Last reviewed commit: 3529802

@sentry
Copy link
Copy Markdown
Contributor

sentry bot commented Feb 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@torlando-tech torlando-tech merged commit b54beaa into main Feb 23, 2026
14 checks passed
@torlando-tech torlando-tech deleted the fix/strip-hostname-uri-scheme branch February 23, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant