stripSDP: use allowlist for a= lines instead of blocklist
All checks were successful
Pin to IPFS / pin (push) Successful in 13s

This commit is contained in:
Niels Göttsch 2026-06-14 19:32:03 +02:00
parent 654d79c58f
commit 13a2ca68f5
No known key found for this signature in database
GPG key ID: E325AC85B57E4370

View file

@ -71,9 +71,16 @@ function hexToBuf(hex) {
/* ─── QR compression: deflate-raw + base45 ─── */
const SDP_ALLOW_A_PREFIXES = ['a=ice-ufrag:', 'a=ice-pwd:', 'a=fingerprint:', 'a=candidate:', 'a=end-of-candidates'];
function stripSDP(sdp) {
return sdp.split(/\r?\n/).map(line => {
if (line === '' || line.startsWith('a=max-message-size:') || line.startsWith('a=sctp-port:')) return null;
return sdp.split(/\r?\n/).filter(line => {
if (!line) return false;
if (line.startsWith('a=')) {
return SDP_ALLOW_A_PREFIXES.some(p => line.startsWith(p));
}
return true;
}).map(line => {
if (!line.startsWith('a=candidate:')) return line;
const parts = line.split(' ');
if (parts[2] === 'tcp') return null;