Repository navigation
fix: validate profile links against pubky.app rules - #2126
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The latest changes appear safe to merge and address the reported link-error problems. SummaryThis PR checks profile links before saving and shows errors beside the fields that need fixing.
Reviews (2) · Last reviewed commit: "fix: keep a pubky.app link refusal on it..." · Reviewed by Greptile |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Validates profile links against the pubky.app rules Paykit enforces (title and URL length, a URL url::Url::parse accepts, http(s) only for new links), shows the error inline in Add Link and under stored rows once the link list changes, and moves link normalization into PubkyAppLink.kt. Reviewed 381aca948, full tier.
What I checked, and 4 candidates I ruled out
Read in full: PubkyAppLink.kt, String.kt (isWebLink), PaykitExceptionExt.kt, EditProfileViewModel.kt, AddLinkSheet.kt, the save and fitted paths of PubkyRepo.kt.
Moved code: singleLine, toPubkyAppLinkUrl, isEmailAddress, isPhoneNumber moved from PubkyRepo to PubkyAppLink.kt; the only behaviour change there is scheme detection by regex instead of java.net.URI, which the body names.
Call sites traced: isWebLink (now only pubkyAppLinkError), toPubkyAppLinkUrl (save, fitted, rejectedLinkIndex), isSocialV1WebUri (fitted, rejectedLinkIndex).
CI at this head: lint and Greptile green; build-and-test and compose-ui pending. Static review: on bitkit-android the PR's branch is not built or run by this reviewer, so this rests on the code and on CI.
Ruled out
- Stored invalid link blocking an unrelated save:
linkErrorsis empty whilelinks == storedLinks, andPubkyReposends links only when they differ from the base, so an untouched bad link never blocks name or bio edits. - Stale row mark after an edit:
rejectedLinkIndexis cleared on add, edit and remove, so a mark never points at a shifted row. - Validation stricter than the save: the check runs on the same normalized URL the save sends (
toPubkyAppLinkUrl), so a bare domain is measured with itshttps://. - Contact links:
webLinksOnlystays false there, so Contacts keeps accepting any text, as stated.
Merge confidence: 4/5, no findings and the rules are covered by PubkyAppLinkTest.kt and EditProfileViewModelTest.kt, but build-and-test is still pending and the branch was not run here.
Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the session metadata names the model, not a reasoning setting)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Verdict: 💬 Comment — draft candidate verified at c53b977; no findings.
Findings: None.
QA for c53b977: DevDebug on Android 16 (API 36.1), staging/regtest, disposable unfunded profile. J1 and manual cases 1–2 used the pristine build; manual case 3 used the input-seeding hook below.
Reject malformed profile links and save a bare domain ✅ Malformed text and email were refused; a bare domain saved successfully.
J1: the inline URL error disabled Add Link Save for not a url and me@example.com. example.com cleared the error and enabled Save. The profile showed “Profile saved”, and reopening the editor showed https://example.com.
J1-2x.2x.mp4
Enforce the label length limit ✅ 100 code points were accepted and 101 refused, with both ASCII and emoji.
Manual 1: both 101-character inputs showed the label error and disabled Save; reducing either to 100 cleared it and enabled Save. Counts were checked by comparing the field's full UI text with the exact input strings.
1-2x.2x.mp4
Count the URL scheme in the length limit ✅ 300 normalized code points enabled Save; 301 showed the length error.
Manual 2: example.com/ plus 281 ASCII characters was refused; 280 was accepted. The exact field text was checked, and the count includes the eight-character https:// prefix.
2-2x.2x.mp4
Check stored invalid links only when links change ✅ The stored row blocked Save after adding a link, and removing it enabled Save.
Manual 3, with the hook: a stored 101-character label showed no error while unchanged, including after changing its URL from https://example.com to the equivalent example.com. Adding a valid Blog link marked the stored row with remove-and-add guidance and disabled Save. Removing that row cleared the error and enabled Save.
The hook only seeds the editor's loaded input; validation is unchanged. This checks the form behavior, without publishing a synthetic invalid profile or creating one through another client.
3-2x.2x.mp4
Test hook — not pushed
diff --git a/app/src/main/java/to/bitkit/ui/screens/profile/EditProfileViewModel.kt b/app/src/main/java/to/bitkit/ui/screens/profile/EditProfileViewModel.kt
index 226709f9a..c65e6bd84 100644
--- a/app/src/main/java/to/bitkit/ui/screens/profile/EditProfileViewModel.kt
+++ b/app/src/main/java/to/bitkit/ui/screens/profile/EditProfileViewModel.kt
@@ -74,7 +74,11 @@ class EditProfileViewModel @Inject constructor(
viewModelScope.launch {
_uiState.update { it.copy(isLoading = true) }
editBase = pubkyRepo.profileEditBase()
- val profile = editBase.profile
+ val profile = editBase.profile?.let { loaded -> // test hook
+ if (to.bitkit.BuildConfig.DEBUG && java.io.File(context.filesDir, "qa-profile-invalid").exists()) { // test hook
+ loaded.copy(links = listOf(PubkyProfileLink("x".repeat(101), "https://example.com"))) // test hook
+ } else loaded // test hook
+ } // test hook
val publicKey = pubkyRepo.publicKey.value.orEmpty()
val removal = if (pubkyRepo.isRingAdoptedIdentity()) ProfileRemoval.UNLINK else ProfileRemoval.DELETE
if (profile != null) {Check: build and focused profile-link tests ✅ DevDebug built and all 309 focused tests passed.
Ran assembleDevDebug and the focused PubkyAppLinkTest, WebLinkTest, PaykitExceptionExtTest, EditProfileViewModelTest, and PubkyRepoTest classes: no failures, errors or skips.
All planned cases passed. The full unit suite was not run. Migration filtering and publisher-refusal mapping/retention were checked in source and focused unit tests; no device case exercised those paths.
Full review: all 31 changed files in 576ac14…c53b977, including shared normalization, profile save, contact callers, translations and journeys. The normalized-comparison fix holds at this head.
Twin: synonymdev/bitkit-ios#1503 at db99adb2c matches the affected validation and error behavior in source; the shared journey matches. No iOS device run was performed here.
Reviewed by gpt-6.1-sol-high
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR diff against its merge base, at c53b977.
No new actionable code findings.
No new actionable code findings. Validation rules, normalization, and error-context matching align with pinned Paykit v0.1.1-rc9 (paykit-sdk/src/domain/contacts/pubky_app.rs, validate_links and validate_social_v1_update). The earlier Greptile review thread (marked resolved) on raw-versus-normalized link comparison is verified fixed at c53b977: EditProfileUiState.linkErrors normalizes links with singleLine() and toPubkyAppLinkUrl() before comparing with storedLinks, matching PubkyRepo.writeProfileOnce. All 16 locale strings.xml files contain the 5 new keys in alphabetical order with valid %1$s formatting, Contacts' AddLinkSheet caller keeps webLinksOnly = false, and the changelog fragment follows repo conventions.
Twin parity: Compared against synonymdev/bitkit-ios#1503 at db99adb (base edce3cd). Link validation, isWebLink, isSocialV1WebUri, stored-link/refusal handling, inline error copy, test tags/accessibility identifiers, and journeys/profile/profile-link-validation.xml match across both platforms. Source inspection alone does not establish visual layout equivalence (for example, compact bottom-sheet fit at large font scales).
Validation and limits: Local Gradle execution was unavailable in this environment (no Android SDK configured), so local unit tests were not executed here. At c53b977, CI passed for build-and-test, compose-ui / ui-tests, lint, and detekt.
Ready for device testing: Yes — no unresolved code concerns remain at c53b977.
Device testing: not performed in this review. Separately, an external reviewer report at c53b977 recorded DevDebug runs on Android 16 for J1 and manual cases 1–2 on a pristine build and manual case 3 using a local debug hook to seed an overlong stored label.
Suggested additional test cases
- Android — Social v1 save-time refusal persistence: On a social v1 profile that already holds a stored non-web link (e.g.
mailto:a@example.comwritten before migration or externally) alongside a valid link, open Edit Profile, add another valid web link, and tap Save. Verify the error toast names the stored link (Fix the <label> link to save your profile.), that row showsEnter a valid web link, such as example.com., and Save stays disabled after editing or removing a different link until the refused link itself is changed to a valid web URL or removed. - Android — Contacts Add Link regression: Open Edit Contact → Add Link, open Suggestions to confirm
EmailandPhoneremain available, and enterme@example.comor+1 234 567 890with a nonblank label. Verify no inline error is shown and Save stays enabled.
Reviewer model: gemini-4-neon
Reasoning effort: high
|
Merged: approved by @piotr-iohk on c53b977, J1 and manual cases 1–3 passed on an Android 16 run of that head, checks green, no open threads. |
Fixes #1882
Twin: synonymdev/bitkit-ios#1503
Edit Profile's Add Link sheet accepted any nonblank label and URL, but Paykit refuses to publish a profile to pubky.app when a link's title is over 100 Unicode code points, its URL is over 300, or the URL does not parse. Because the publisher checks every link whenever the link list changes, one bad link blocked saving all other edits with a generic error (Greptile finding).
Description
v0.1.1-rc9(paykit-sdk/src/domain/contacts/pubky_app.rs,validate_links), which re-implements the pubky-app-specsPubkyAppUserLinkrules: title trimmed, non-empty, no control characters, at most 100 chars; URL trimmed, at most 300 chars,url::Url::parsemust succeed; on a social v1 profile the URL must also behttp(s)://with a host. The Paykit bindings expose no validator, so the app checks the same rules itself, after the normalization the save already does (bare domain gainshttps://).mailto:link), the toast names the link ("Fix the link to save your profile.") and that row is marked, instead of the raw Paykit error.url::Url::parserefuses (a control character, an empty or forbidden-character host on a special URL, a port over 65535, a host ending in a non-IPv4 all-digit label). Paths and queries the parser accepts, such as?q=a|b, a bare%or brackets, are accepted, so profiles that saved before still save. The same check runs on both apps.isWebLinkuses the same check, so IDN and underscore hosts (bücher.de,my_site.example.com) are accepted as web links, as on iOS. Localhost and IP hosts are unchanged.Out of Scope
url::Url::parse, left as they are: a percent-encoded host (https://%65xample.com) is refused, as are hex or octal IPv4 forms; invalid IDNA and malformed IPv6 hosts are accepted here and refused by Paykit; ports onfile:URLs are not checked. None of these are links people type.Design
Add Link populated (Handoff v63, Profile). Figma has no error state, so the error uses the app's existing inline field error (red text under the field, as in Add Contact).
Preview
Device screenshots: pending device run.
QA Notes
Setup
Dev/regtest build of this branch. A disposable wallet signed in to a Pubky profile with at most four links, PIN off, English. No funds needed.
Journeys
profile-link-validation.xml— Add Link shows an inline error and keeps Save disabled for an invalid URL or an email, and accepts a bare domainManual Tests
example.com→ label error, Save disabled; 100 characters → accepted — long text input is not reliable through the journey runnerexample.com/plus 281a(301 withhttps://) → URL length error; one fewer → accepted — long text input is not reliable through the journey runnerAutomated Checks
added
PubkyAppLinkTest.kt— 100/101 code points with emoji, 300/301 after normalization, invalid URLs, normalizable inputs, web-only refusal,|/%/brackets in paths, forbidden host characters, ports over 65535, control characters, empty labelsupdated
WebLinkTest.kt— IDN, underscore and query-with-|hosts are web linksupdated
PaykitExceptionExtTest.kt— only Paykit 0.1.1-rc9's exact non-web link context is a non-web link rejectionupdated
EditProfileViewModelTest.kt— a stored URL the parser accepts does not block the save, another link refusal marks no row, unchanged stored links are not checked, a bad stored link blocks the save once links change, an added link is held to the limits, a Paykit link refusal points to the stored non-web linkadded
EditProfileViewModelTest.kt— a url edit that normalizes to the stored link leaves stored links uncheckedadded
EditProfileViewModelTest.kt— a pubky app refusal stays on its link until that link changesEvidence
Device screenshots: pending device run.
Local, commit
c53b977da:compileDevDebugKotlin,detektandlintDevDebugpass. Unit testsEditProfileViewModelTest(26),PubkyAppLinkTest(11) andPubkyRepoTest(259): 0 failures. The full unit suite was not run (shared machine, targeted classes only).Gaps
Device cases J1 and 1-3 not run yet (pending device run). Case 3 needs a profile with a stored invalid link, which this build cannot create.
Review
Independent review by
claude-opus-5-5, round 1, at the first commit. No HIGH findings; the label rules, code-point counting and normalize-then-validate order matched Paykit. Fixed in6593d03ac:java.net.URI, which refuses|, brackets, braces,^,"and a bare%thaturl::Url::parseaccepts, so a stored link such ashttps://example.com/?q=a|bwould block Save; a failed parse also producedhttps://https://…. Both apps now use the same WHATWG-style check and detect the scheme with a regex.https://with no host on stored rows (iOS), and labels made only of control characters were accepted although Paykit refuses them. All refused now, with tests.isWebLinkrefused IDN and underscore hosts; it now uses the same check.Round 2, re-review by
claude-opus-5-5of round 1. Fixed inb7acee00a:isWebLinkacceptedhttps:example.com,https:/example.comandhttps:\\example.com, as WHATWG skips slashes after a special scheme, while Paykit needs the literalhttp://orhttps://. It now requires//after the scheme and no\in the authority.https://example.com.) was refused; one trailing dot is now dropped before the IPv4 and top-label checks.Content; the URL check reusesURI_SCHEME.Round 3, re-review by
claude-opus-5-5of round 2. Fixed in406a4aba2:isWebLinkaccepted an empty authority with extra slashes (https:///example.com,https:////example.com, and/example.com, which becomeshttps:///…), which Paykit refuses. The host is now read as Paykit'sis_social_v1_web_urireads it (authority up to/,?or#, after the last@, up to:unless it starts with[) and must be non-empty;https://.andhttps://..are refused too.singleLinedoes, soLine1\nLine2keeps its word break.Char.isWhitespacealso checksCharacter.isSpaceChar. Tests added toWebLinkTest; no code change.Round 3 result, re-review by
claude-opus-5-5of round 3: no HIGH or MEDIUM. LOW findings fixed in381aca948:http(s)://prefix, so a legacyhttps:///example.compassed it and failed the save. It now uses a Paykit-exact predicate (is_social_v1_web_uri: lowercasehttp://orhttps://, no control or whitespace character, non-empty host).https://localhostorhttps://[::1]could be blamed. It now uses the same Paykit-exact predicate on the normalized URL;isWebLinkstays for input.Review round (Greptile):
https://example.comtoexample.com) could block a save with a stored over-long label. Verdict: real. Fixed inb503a4229.c53b977da.Models used
claude-opus-5-5(reasoning:Not exposed)claude-opus-5-5(reasoning:Not exposed)claude-opus-5-5(reasoning:Not exposed)The session metadata available to the agent names the model but not a reasoning setting.
🤖 Generated with Claude Code