File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 4141 const content = msg . params ?. content ;
4242 const img = content ?. find ( c => c . type === 'image' ) ;
4343 if ( img ) {
44- document . getElementById ( 'qr' ) . innerHTML =
45- `<img src="data:${ img . mimeType } ;base64,${ img . data } " alt="QR Code"/>` ;
44+ const qrDiv = document . getElementById ( 'qr' ) ;
45+ qrDiv . innerHTML = '' ; // clear previous content
46+
47+ // Optionally allowlist mimetypes
48+ const allowedTypes = [ 'image/png' , 'image/jpeg' , 'image/gif' ] ;
49+ const mimeType = allowedTypes . includes ( img . mimeType ) ? img . mimeType : 'image/png' ;
50+
51+ const image = document . createElement ( 'img' ) ;
52+ image . src = `data:${ mimeType } ;base64,${ img . data } ` ;
53+ image . alt = "QR Code" ;
54+ qrDiv . appendChild ( image ) ;
4655
4756 // Report size to host
4857 window . parent . postMessage ( {
You can’t perform that action at this time.
0 commit comments