Skip to content

Guard against nil redirect/url on LiveView join - #4516

Merged
SteffenDE merged 1 commit into
phoenixframework:mainfrom
francocatena:null-redirect
Nov 24, 2026
Merged

SteffenDE merged 1 commit into
phoenixframework:mainfrom
francocatena:null-redirect

Conversation

@francocatena

@francocatena francocatena commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

A join payload with "redirect": null (or "url": null) crashed the channel with a FunctionClauseError in Route.live_link_info_without_checks/3. authorize_session/3 matched on the key without checking the value, so nil was passed on to route matching. The official JS client never sends these values, but any client can.

This adds when is_binary(url) guards to both clauses:

  • A nil redirect now falls through to the "url" clause and the join works normally.
  • A nil url falls through to the catch-all clauses. Router-mounted LiveViews reject the join as unauthorized, and others mount without a route, as they do when the url is absent.

It also adds regression tests for both cases in router_test.exs.

@SteffenDE
SteffenDE merged commit 62674c2 into phoenixframework:main Nov 24, 2026
9 checks passed
@SteffenDE

Copy link
Copy Markdown
Member

Thank you!

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.

2 participants