Repository navigation
fix: validate profile links against pubky.app rules - #1503
Conversation
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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The PR appears safe to merge; the latest changes address the reported problems without introducing a new actionable issue. SummaryAdds profile-link checks, inline errors, translated messages, and regression tests.
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 Edit Profile and Add Link input against the link rules Paykit 0.1.1-rc9 applies before publishing to pubky.app (title, URL length, url::Url::parse, the social v1 web-URL rule), and maps Paykit's non-web refusal to the offending row. Reviewed 96785bbef, full tier, static only: Bitkit iOS does not build on this reviewer's Linux machine, so this is reasoned from the code and CI.
What I checked, and 6 candidates I ruled out
Read in full: PubkyAppProfileStore.swift (the link helpers, fitted, normalized, update(from:base:)), PubkyProfile.swift, AddLinkSheet.swift, EditProfileView.swift, ProfileEditFormView.swift, PubkyAppLinkTests.swift, WebLinkTests.swift
Compared against: Paykit v0.1.1-rc9 paykit-sdk/src/domain/contacts/pubky_app.rs (validate_links, max_chars, uri, validate_social_v1_update, is_social_v1_web_uri), the version Package.resolved pins
Call sites traced: both ProfileEditFormView( callers (Edit Profile, Edit Contact), every linkUrl( and isWebLink caller
CI: SwiftFormat failed on a segfault of swiftformat_linux (exit 139), and the same head passed the lint workflow at 17:56; build-local failed its "Checked-out merge does not match the PR's current base and head" step, a checkout race, not a build error. Unit and integration tests were still running at review time.
Ruled out
isSocialV1WebUrldrifts from Paykit: same lowercase prefix, ASCII-control and UnicodeWhite_Spacerefusal, last-@split and[/:host read asis_social_v1_web_uri.- Label or URL counted differently: Paykit counts
chars(), the app countsunicodeScalars, and the label is checked aftersingleLine, which is whatnormalizedsends. - Row refusal points at the wrong link:
rejectedLinkIndexre-applieslinkUrl(...) ?? url, the exact transformnormalizedapplies before the publish. - Unchanged stored links blocked:
linkErrorsreturns empty while the links equal the stored ones, andupdate(from:base:)sendslinks: nilthen, so Paykit skipsvalidate_links. - Edit Contact loses its old behaviour: it passes neither
webLinksOnlynorlinkErrors, so Save keeps its name-only gate as on master. - Static members of the
actorcalled from views: static members are not actor-isolated, and the new static lets areSendable. - The rejected-row reset on any link edit is already raised by Greptile on
EditProfileView.swift.
Merge confidence: 3/5, CI is red for reasons not tied to the diff (a SwiftFormat crash, a merge-checkout mismatch) and the unit tests had not finished.
Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the runtime does not report a reasoning setting for this session)
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: ✅ Approve
Findings: None.
QA for db99adb: Debug/regtest build on iPhone 17 Pro 2x, iOS 27.0, English, disposable unfunded wallet and staging Pubky profile.
J1: Reject invalid links and save a bare domain ✅ Invalid URL and email kept Save disabled; example.com saved as https://example.com with the Profile updated toast.
J1-2x.2x.mp4
1: Enforce the label length limit ✅ 101 code points showed an error and disabled Save; 100 cleared the error and enabled Save.
Input lengths were checked from accessibility values.
label-2x.2x.mp4
2: Enforce URL length after normalization ✅ 301 code points after adding https:// showed an error and disabled Save; 300 cleared the error and enabled Save.
Input lengths were checked from accessibility values.
url-2x.2x.mp4
3: Identify a stored invalid link after links change ✅ With a seeded invalid loaded link, adding Blog marked the invalid row and disabled Save; removing that row enabled Save again.
The unchanged invalid link initially showed no error and left Save enabled. This case used db99adb plus a local debug hook to seed the loaded form state; it did not create an invalid remote profile.
stored-2x.2x.mp4
Test hook
Not pushed. Seeds Legacy invalid in the editor's current and stored link arrays; validation and Save decisions are unchanged.
diff --git a/Bitkit/Views/Profile/EditProfileView.swift b/Bitkit/Views/Profile/EditProfileView.swift
index 003a3f6fd..697991599 100644
--- a/Bitkit/Views/Profile/EditProfileView.swift
+++ b/Bitkit/Views/Profile/EditProfileView.swift
@@ -172,6 +172,14 @@ struct EditProfileView: View {
links = profile.links.map { ProfileLinkInput(label: $0.label, url: $0.url) }
storedLinks = profile.links.map { PubkyProfileData.Link(label: $0.label, url: $0.url) }
rejectedLink = nil
+ #if DEBUG // test hook
+ if ProcessInfo.processInfo.arguments.contains("-review-invalid-link") { // test hook
+ let invalid = PubkyProfileData.Link(label: "Legacy invalid", url: "not a url") // test hook
+ links.append(ProfileLinkInput(label: invalid.label, url: invalid.url)) // test hook
+ storedLinks.append(invalid) // test hook
+ Logger.info("Test hook seeded Legacy invalid in current and stored links", context: "Review1503") // test hook
+ } // test hook
+ #endif // test hook
tags = profile.tags
baseRevision = profile.revision
baseTagsUnread = profile.tagsUnreadINFOℹ️: Test hook seeded Legacy invalid in current and stored links - Review1503 [EditProfileView.swift: loadProfileData() line: 180]
Check: Link validation and profile publishing helpers ✅ Targeted unit tests, changed-file SwiftFormat 0.64.6 lint and translation validation passed.
Ran PubkyAppLinkTests, PubkyAppProfileStoreTests and WebLinkTests, including refusal retention, normalized unchanged links, Unicode limits and publisher error mapping.
No planned case was left unrun.
Full review: edce3cd..db99adb, including profile/contact form callers, normalization, publishing, migration, locale additions and test isolation. The migration branch and save-time non-web refusal were checked through code and unit tests; device cases cover pre-save validation and normal publication. The rare parser differences listed under Out of Scope remain outside this review.
Twin: synonymdev/bitkit-android#2126 matches the validation, normalization and refusal-retention behavior inspected here; Android was not device-tested in this run.
The earlier static review covered 96785bb. The refusal-retention fix was checked at db99adb against the view and regression test.
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 db99adb.
No new actionable code findings.
All link normalization, validation, social v1 predicate, and Paykit rejection-mapping changes match pinned Paykit v0.1.1-rc9 (pubky/paykit-rs paykit-sdk/src/domain/contacts/pubky_app.rs, 0b9c63d) and align with the Android twin synonymdev/bitkit-android#2126 at c53b977. EditContactView keeps unrestricted contact links, and journeys/profile/profile-link-validation.xml identifiers match both platforms. The previously resolved Greptile thread (#discussion_r4712407195) is verified fixed at db99adb: EditProfileView retains rejectedLink by value across unrelated edits and row removals, backed by PubkyAppLinkTests.testRefusalStaysOnItsLinkUntilThatLinkChanges.
Validation & limitations: Local node scripts/validate-translations.js passed with 0 errors across all 15 locales. On db99adb, CI Run Tests, Run Integration Tests, SwiftFormat, and validate passed. build-local failed its pre-build merge-ref freshness check (Checked-out merge does not match the PR's current base and head, unrelated to the diff). Native Swift compilation and Xcode tests could not be run locally on this Linux host, and visual layout of inline error text inside AddLinkSheet and ProfileEditFormView was not verified at runtime.
Suggested additional test cases
- iOS — Contacts → Add Link remains unrestricted: Open an existing contact → Edit Contact → Add Link, enter a non-empty label with
me@example.comornot a url, and confirm no inline link error appears and Save remains enabled. - iOS — Social v1 save-time refusal stays on its row: On a social v1 profile with a stored non-web link (e.g.,
mailto:a@example.com) and another valid link, add a new web link and tap Save; confirm the error toast names the non-web link and marks its row, editing or removing another row keeps that row marked and Save disabled, and fixing or removing the marked link re-enables Save.
Ready for device testing.
Device testing: not performed in this review (code-only). ovi-reviewer's review reports running J1 and manual cases 1–3 on db99adb (with case 3 seeded via a local debug hook).
Reviewer model: gemini-4-neon
Reasoning effort: high
{"kind":"bitkit-retarget-execution-v1","repository":"synonymdev/bitkit-ios","pr":1503,"generation":"45964992159-1","sourceSha":"003a8dc146e649f4534472458f04dc1f697f76de","sourceRef":"003a8dc146e649f4534472458f04dc1f697f76de","owner":"github-actions[bot]"}
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR at bb396f5, re-reviewed because the comparison base moved to 676956b. The head adds only a merge of master. The PR's own source, test and journey files are byte-identical to the previously reviewed db99adb.
No new actionable code findings.
The new link rules match Paykit 0.1.1-rc9 (paykit-sdk/src/domain/contacts/pubky_app.rs at 0b9c63d), the version Package.resolved pins. That covers the label and URL limits counted after Paykit's trim, the refusal of control characters, the empty-title rule, the web-only (social v1) predicate, and the order of the generic and social v1 checks. The exact error text the app matches to mark a refused link reaches the app unchanged. The save path still sends links only when they differ from the stored ones after normalization, and the form gate uses the same comparison. Edit Contact still accepts any link text.
Validation and limits: I extracted the link helpers from the pinned source into a Linux Swift 6.4.2 package (Paykit error type stubbed) and ran the PR's PubkyAppLinkTests and WebLinkTests there: 23 tests, 0 failures. This is Linux Foundation, not an iOS build. A wider probe of common inputs (bare domains, IDN, | and % in queries, ports, trailing dot, email, phone) gave the expected accept or refuse result. scripts/validate-translations.js passes for every locale. crates.io was not reachable from this sandbox, so I could not run url::Url::parse itself. The rare parser differences the PR lists as out of scope remain unverified at runtime. At this head, CI Run Tests, Run Integration Tests and build-local were still pending.
Parity: Compared with the Android twin synonymdev/bitkit-android#2126 at c53b977: journeys/profile/profile-link-validation.xml is identical on both platforms. Stored-link checking, the unchanged-links short-circuit and keeping a refusal on its link match too.
Existing threads: The Greptile thread on a refusal being cleared by unrelated edits is marked resolved, and the fix holds at this head. rejectedLink is kept by value and is set only when the form still matches the saved links. Its regression test passed in the Linux run.
Recommended before device testing: let the pending Run Tests, Run Integration Tests and build-local jobs finish at bb396f5.
Device testing: not performed in this review. ovi-reviewer reports J1 and manual cases 1–3 passing on db99adb (case 3 with a locally seeded invalid link). The current head differs from it only by the master merge, which does not touch the PR's files.
Suggested additional test cases
- iOS, social v1 profile with a stored
mailto:link written outside Bitkit: add a valid web link and tap Save. Expected: the toast reads "Fix the link to save your profile." and only themailto:row showsProfileEditLinkError_<index>. Then edit a different row's URL. Expected: themailto:row stays marked and Save stays disabled until that row is edited or removed.
Reviewer model: claude-opus-5-5
Reasoning effort: high
Fixes #1301
Twin: synonymdev/bitkit-android#2126
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.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
PubkyAppLinkTests.swift— 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 labels, stored links without a host, stored-link checks and the rejection mapping pinned to Paykit 0.1.1-rc9added
PubkyAppLinkTests.swift— a URL edit that normalizes to the stored link leaves stored links uncheckedadded
PubkyAppLinkTests.swift— a refusal stays on its link until that link changesEvidence
Device screenshots: pending device run.
Local, commit
db99adb2c:xcodebuild testwith-only-testingPubkyAppLinkTests,PubkyAppProfileStoreTests,WebLinkTestson the iPhone 17 Pro simulator: 33 tests, 0 failures. SwiftFormat lint on the changed Swift files: clean.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 in30c9c9578: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.isWebLinkalignment; iOS already accepted IDN and underscore hosts.Round 2, re-review by
claude-opus-5-5of round 1. Fixed in61978829b:https://example.com., which saved before and Paykit accepts; one trailing dot is now dropped before it.isWebLinkusedURLComponentswhile Android uses the hand-written check. iOS now uses the same check, requiring//after the scheme and no\in the authority, sohttps:example.comis refused on both apps.Round 3, re-review by
claude-opus-5-5of round 2. Fixed incb512b9dd: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.Round 3 result, re-review by
claude-opus-5-5of round 3: no HIGH or MEDIUM. LOW findings fixed in96785bbef: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.WebLinkTests, matching Android.Review round (Greptile):
https://example.comtoexample.com) could block a save with a stored over-long label. Verdict: real. Fixed inc9c492466.db99adb2c.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