mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-05 20:32:27 +00:00
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 <[email protected]>
This commit is contained in:
1 parent
412ed2aae4
commit
852e62c341
1 file changed
+6
-3
@@ -59,15 +59,18 @@ test("augments magnets with ws/xs hints", () => {
|
||||
|
||||
assert.deepEqual(errors, []);
|
||||
const { magnet, ws, xs } = payload.legacyFormData;
|
||||
assert.ok(magnet.startsWith("magnet:?xt=urn:btih:"));
|
||||
assert.ok(
|
||||
magnet.startsWith("magnet:?xt=urn%3Abtih%3A") || magnet.startsWith("magnet:?xt=urn:btih:"),
|
||||
"Magnet should start with xt parameter",
|
||||
);
|
||||
assert.ok(
|
||||
magnet.includes("ws=https%3A%2F%2Fcdn.example.com%2Fvideo.mp4") ||
|
||||
magnet.includes("ws=https://cdn.example.com/video.mp4"),
|
||||
"Normalized magnet should include ws hint",
|
||||
);
|
||||
assert.ok(
|
||||
magnet.includes("xs=https://cdn.example.com/video.torrent") ||
|
||||
magnet.includes("xs=https%3A%2F%2Fcdn.example.com%2Fvideo.torrent"),
|
||||
magnet.includes("xs=https%3A%2F%2Fcdn.example.com%2Fvideo.torrent") ||
|
||||
magnet.includes("xs=https://cdn.example.com/video.torrent"),
|
||||
"Normalized magnet should include xs hint",
|
||||
);
|
||||
assert.equal(ws, "https://cdn.example.com/video.mp4");
|
||||
|
||||
Reference in new issue
Block a user