mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-07 21:32:51 +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` to handle encoded magnet URIs.
Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
be66e39ee5
commit
412ed2aae4
1 file changed
+6
-6
@@ -254,19 +254,19 @@ test('editing the magnet refreshes torrent hints when ws/xs remain locked', asyn
|
||||
);
|
||||
assert.ok(
|
||||
submission.updatedData.magnet.includes(
|
||||
'urn:btih:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
|
||||
'urn%3Abtih%3Abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
|
||||
),
|
||||
'normalized magnet should contain the updated info hash',
|
||||
'normalized magnet should contain the updated info hash (encoded)',
|
||||
);
|
||||
assert.ok(
|
||||
submission.updatedData.magnet.includes('ws=https://new.example/video.mp4'),
|
||||
'normalized magnet should include the refreshed ws hint',
|
||||
submission.updatedData.magnet.includes('ws=https%3A%2F%2Fnew.example%2Fvideo.mp4'),
|
||||
'normalized magnet should include the refreshed ws hint (encoded)',
|
||||
);
|
||||
assert.ok(
|
||||
submission.updatedData.magnet.includes(
|
||||
'xs=https://new.example/video.torrent',
|
||||
'xs=https%3A%2F%2Fnew.example%2Fvideo.torrent',
|
||||
),
|
||||
'normalized magnet should include the refreshed xs hint',
|
||||
'normalized magnet should include the refreshed xs hint (encoded)',
|
||||
);
|
||||
|
||||
modal.setSubmitState({ pending: false });
|
||||
|
||||
Reference in new issue
Block a user