Skip to content

fix: resolve favicon links after redirect - #14211

Merged
HarshMN2345 merged 2 commits into
mainfrom
cursor/favicon-redirect-final-url-7b67
Oct 8, 2026
Merged

HarshMN2345 merged 2 commits into
mainfrom
cursor/favicon-redirect-final-url-7b67

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Fixes favicon resolution after a website redirects. safeFetch() followed redirects but dropped the URL it landed on, so relative <link rel="icon"> hrefs and the /favicon.ico fallback were resolved against the original request.

safeFetch() now reports the last URL it requested, and the action resolves icon links and the /favicon.ico fallback against it. The fallback goes through URL::resolveLocation() instead of rebuilding scheme://host, so it also keeps a non-default port.

Fixes #13985

Test Plan

Ran the action against a real redirect, https://httpbin.org/redirect-to?url=https://appwrite.io/:

Icon requested Result
Before https://httpbin.org/logo.svg 404, avatar_icon_not_found
After https://appwrite.io/logo.svg 200, image/svg+xml

https://github.com/ (no redirect) still returns its absolute SVG icon. tests/unit/Network/FetcherTest.php passes unchanged, and Pint and PHPStan are clean on the changed file.

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

32 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (17)
  • php.appwrite.permissive-write-permission (8)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → cursor/favicon-redirect-final-url-7b67 (after).

Metric Before After Change
🚀 Requests/sec 202.05 205.26 ⚪ +1.6%
⏱️ Latency P50 86.66 ms 84.09 ms ⚪ -3%
⏱️ Latency P95 198.92 ms 200.26 ms ⚪ +0.7%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 84.09 200.26 12,597 205.26 +1.34
Account 165.46 298.09 663 11.11 -9.44
TablesDB 79.45 149.59 6,851 113.22 +0.07
Storage 81.47 176.91 3,315 56.71 +0.16
Functions 122.27 242.35 1,768 30.88 +2.16

Top API waits (after)

API request Max wait (ms)
account.name.update 478.67
account.prefs.update 407.68
functions.variables.update 389.61
functions.variables.create 358.79
functions.create 338.56

Copy link
Copy Markdown
Member Author

@hansi-codes review

@ghost

ghost commented Oct 7, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The favicon action now captures the last URL requested while fetching the page and uses it to resolve relative icon links. Its /favicon.ico fallback is also resolved against that URL, preserving the final origin and non-default port.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 1
File Change
src/Appwrite/Platform/Modules/Avatars/Http/Favicon/Get.php Capture the final page URL from safeFetch and use it as the base for icon and fallback URL resolution.

Reviewed 2214fbb · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · Looks good to merge. Summary

Comment thread tests/unit/Network/FetcherTest.php Resolved
safeFetch followed redirects but discarded the URL it landed on, so relative
icon links and the /favicon.ico fallback were resolved against the original
request.
@cursor
cursor Bot force-pushed the cursor/favicon-redirect-final-url-7b67 branch from b1426b9 to fc7ad2a Compare October 7, 2026 10:04

Copy link
Copy Markdown
Member Author

@hansi-codes review

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

The fix only needs safeFetch to report the URL it landed on; selecting
the icon stays in Get.php instead of a separate Avatars library.
@HarshMN2345
HarshMN2345 marked this pull request as ready for review October 8, 2026 11:47
@luxor-code-review

luxor-code-review Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR modifies the favicon fetch action (src/Appwrite/Platform/Modules/Avatars/Http/Favicon/Get.php). The change was reviewed across correctness, security, SSRF/outbound-fetch hardening, and holistic architectural lenses; no defects met the reporting threshold.

Files Change
src/Appwrite/Platform/Modules/Avatars/Http/Favicon/Get.php Adjusts the favicon fetch logic for the Avatars service.

Reviewed commit: 2214fbb

@HarshMN2345
HarshMN2345 merged commit 963ad60 into main Oct 8, 2026
61 checks passed
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.

Favicon uses the original page URL to resolve relative icon links after a redirect

1 participant