Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves origin matching for the native WebView message bridge by normalizing IPv6 hosts so that bracketed ([fd00::1]) vs unbracketed (fd00::1) representations compare consistently when evaluating WKSecurityOrigin.
Changes:
- Normalize host strings by lowercasing and stripping surrounding
[]when present. - Add unit test coverage to ensure main-frame messages from a configured IPv6 origin are allowed for both bracketed and unbracketed host formats.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Tests/App/WebView/SafeScriptMessageHandlerTests.swift | Adds regression test covering bracketed vs unbracketed IPv6 host handling. |
| Sources/App/Frontend/ExternalMessageBus/SafeScriptMessageHandler.swift | Normalizes host strings (including bracket stripping) when computing origin comparison keys. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4602 +/- ##
=======================================
Coverage ? 43.23%
=======================================
Files ? 277
Lines ? 16735
Branches ? 0
=======================================
Hits ? 7236
Misses ? 9499
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The issue is the new WebView bridge origin check. It compares configured URL hosts with WKSecurityOrigin.host and IPv6 can appear as fd00::abcd in one API and [fd00::abcd] in another, so the bridge rejects valid frontend messages. That blocks external auth and leaves the frontend loading, while widgets still work.
This PR normalizes the url
Screenshots
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
Any other notes