Self-hosted web view login cookie check fails for usernames containing `@` or spaces
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- ios, objective-c, swift
- Domain
- authentication, mobile, mobile-dev
Research direction
Start in WordPress/Classes/Utility/WebViewController/CookieJar.swift at HTTPCookie.isWordPressLoggedIn(username:), which currently takes everything before the first % as the username. Percent-decode the cookie value (PHP also maps spaces to +) and split on |, matching isWordPressLoggedInAtomic(username:). Confirm AuthenticationService.loadAuthCookiesForSelfHosted no longer re-POSTs to wp-login.php for usernames like [email protected] and john doe.
Written by the indexing model from the issue text.
Description
Found while reviewing #26103. Pre-existing — not introduced by that PR, and unchanged by #26106 and #26104.
The logged-in cookie check for self-hosted sites never matches when the username contains a character that PHP URL-encodes, so the app logs in again before every authenticated web view load.
Root cause
HTTPCookie.isWordPressLoggedIn(username:) takes the username to be everything before the first % in the cookie value:
WordPress sets the cookie value to username|expiration|token|hmac and PHP's setcookie() URL-encodes it, so the check relies on the first | arriving as %7C. An encoded character inside the username breaks that:
| Username | Cookie value | Parsed username | Match |
|---|---|---|---|
admin |
admin%7C… |
admin |
✅ |
[email protected] |
user%40example.com%7C… |
user |
❌ |
john doe |
john+doe%7C… |
john+doe |
❌ |
Impact
AuthenticationService.loadAuthCookiesForSelfHosted treats a failed check as "no cookie" and POSTs the username and password to wp-login.php again:
This affects sites that RequestAuthenticator authenticates with .siteLogin credentials. The login itself still succeeds, so the cost is an extra login round-trip — and a new session on the site — before each authenticated load, rather than a visible failure.
WordPress.com usernames are normally limited to lowercase letters and numbers, so the same predicate is not expected to misfire on the WordPress.com path.
Verification
Confirmed with a Foundation probe (macOS 27.0.1): HTTPCookie.cookies(withResponseHeaderFields:for:) keeps the value percent-encoded, and the predicate returns false for [email protected] and john doe.
The cookie values in the probe were built from WordPress's cookie format. We have not reproduced this against a live self-hosted site.
Suggested fix
Percent-decode the value before parsing — PHP's urlencode also turns spaces into + — and split on |, as isWordPressLoggedInAtomic(username:) already does.
- Dominant language
- Swift
- Stars
- 3.9k
- Forks
- 1.2k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 56
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from wordpress-mobile/WordPress-iOS
-
[Type] Tech Debt Site Creation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
wordpress-mobile/WordPress-iOS#26113 · 1 comment ·
Maintainers usually reply within 1 day
-
[Type] Tech Debt
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
wordpress-mobile/WordPress-iOS#26112 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
wordpress-mobile/WordPress-iOS#25657 · 1 comment ·
Maintainers usually reply within 1 day
-
Rename Stats Insight cards for clarityPossibly taken @amitraj2203 claimed this 55 days ago. Open[Pri] Low [Type] Enhancement Stats
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
wordpress-mobile/WordPress-iOS#23015 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Remove Google Plus mentionsPossibly taken A pull request linked to this issue is open or already merged. Open[Type] Tech Debt Good First Issue Sharing
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
wordpress-mobile/WordPress-iOS#20142 · 15 comments ·
Maintainers usually reply within 1 day
All issues in wordpress-mobile/WordPress-iOS
Similar issues
-
#️⃣ REX and feebacks 🔍 triage 🧑💻 Developer eXperience 🧰 library
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Orange-OpenSource/ouds-ios#1795 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
RodnaPamet/agrent-ios#172 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug iOS 🍎 ui/ux
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
MerginMaps/mobile#4744 ·
Maintainers usually reply within 1 day
-
bug milestone-qa mobile
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
lognorman20/monaco#3519 ·