Skip to content

Only return to paths on this site after deleting - #156

Open
wayx112 wants to merge 1 commit into
Team6083:mainfrom
wayx112:fix/safe-return-to
Open

wayx112 wants to merge 1 commit into
Team6083:mainfrom
wayx112:fix/safe-return-to

Conversation

@wayx112

@wayx112 wayx112 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Summary

The delete pages for time logs and stat ranges redirect to ?returnTo= after Cancel or Delete, and used the value as is. A link such as /logs/{id}/delete?returnTo=https://example.com/ sent the admin to another site after either button, e.g. a look-alike sign-in page in a phishing message.

  • safeReturnTo(value, fallback) (src/lib/util.ts) keeps a path that starts with a single / and falls back to the page's usual list otherwise. //host, /\host, full URLs and javascript: all fall back.
  • Used on /logs/{id}/delete and /admin/stat-ranges/{id}/delete. The home page's own returnTo=/ still works.

Evidence

On a local preview, signed in as an admin:

/logs/{id}/delete?returnTo=https://example.com/, Cancel
  before:  lands on https://example.com
  after:   lands on /logs
Test Files  25 passed (25)
     Tests  335 passed (335)

New tests for safeReturnTo. tsc --noEmit, ESLint on the changed files and npm run build pass.

Merge danger

Door: two-way. Two pages and one helper.

Blast radius: where Cancel and Delete go on the two delete pages.

🤖 Generated with Claude Code

The delete pages for time logs and stat ranges redirect to `?returnTo=` after Cancel or Delete, and took any value. A link like /logs/{id}/delete?returnTo=https://example.com/ sent an admin to another site, e.g. a look-alike sign-in page. returnTo now has to be a path starting with a single "/"; anything else goes to the page's usual list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant