From 57551a8acd0f7538b90fedf9eb8ad508fed09772 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 11 Feb 2026 11:41:17 +0000 Subject: [PATCH] security: fix magnet parameter injection and data loss - Fix magnet parameter injection vulnerability in `js/magnetShared.js` by ensuring all parameter values are decoded during normalization and re-encoded during URI construction. - Fix a data loss bug in `normalizeMagnetInput` where parameter values containing `=` were truncated due to `split("=", 2)`. - Consistently decode all magnet parameter values to ensure a clean internal representation. - Use `encodeURIComponent` in `buildMagnetUri` to safely reconstruct the magnet URI. - Update `tests/edit-modal-submit-state.test.mjs` and `tests/video-note-payload.test.mjs` to handle encoded magnet URIs. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- tests/video-note-payload.test.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/video-note-payload.test.mjs b/tests/video-note-payload.test.mjs index 0a2e037a..110cb24c 100644 --- a/tests/video-note-payload.test.mjs +++ b/tests/video-note-payload.test.mjs @@ -60,8 +60,8 @@ test("augments magnets with ws/xs hints", () => { assert.deepEqual(errors, []); const { magnet, ws, xs } = payload.legacyFormData; assert.ok( - magnet.startsWith("magnet:?xt=urn%3Abtih%3A") || magnet.startsWith("magnet:?xt=urn:btih:"), - "Magnet should start with xt parameter", + magnet.startsWith("magnet:?xt=urn%3Abtih%3A"), + "Magnet should start with xt parameter (encoded)", ); assert.ok( magnet.includes("ws=https%3A%2F%2Fcdn.example.com%2Fvideo.mp4") ||