Skip to content

Commit 3a85868

Browse files
KMchaudharyKMchaudhary
andauthored
Fix the gallery block console errors, occure due to rtmedia plugin (#1530)
* Fix the gallery block console errors, occure due to rtmedia plugin * Fix github advance security issue: DOM text reinterpreted as HTML --------- Co-authored-by: KMchaudhary <kuldipkumar.chaudhary@rtcamp.com>
1 parent 94177b3 commit 3a85868

2 files changed

Lines changed: 41 additions & 12 deletions

File tree

assets/src/js/godam-player/engagement.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,18 +1166,35 @@ function CommentBox( props ) {
11661166

11671167
useEffect( () => {
11681168
const currentVideoParent = document.getElementById( videoFigureId );
1169+
1170+
if ( ! currentVideoParent ) {
1171+
return;
1172+
}
1173+
11691174
const currentVideo = currentVideoParent.querySelector( '.godam-video-wrapper' );
1175+
1176+
if ( ! currentVideo ) {
1177+
return;
1178+
}
1179+
1180+
const videoContainer = videoContainerRef.current;
1181+
1182+
if ( ! videoContainer ) {
1183+
return;
1184+
}
1185+
11701186
const currentVideoClass = currentVideoParent.className;
11711187
const currentVideoStyles = currentVideoParent.getAttribute( 'style' );
11721188

1173-
const videoContainer = videoContainerRef.current;
11741189
videoContainer.className = currentVideoClass;
11751190
videoContainer.style = currentVideoStyles;
11761191
videoContainer.appendChild( currentVideo );
11771192
document.body.classList.add( 'no-scroll' );
11781193

11791194
return () => {
1180-
currentVideoParent.insertBefore( currentVideo, currentVideoParent.firstChild );
1195+
if ( currentVideoParent && currentVideo ) {
1196+
currentVideoParent.insertBefore( currentVideo, currentVideoParent.firstChild );
1197+
}
11811198
document.body.classList.remove( 'no-scroll' );
11821199

11831200
// Godam gallery cleanup if needed

assets/src/js/ninja-forms/ninja-forms-submissions-list.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,28 @@ document.addEventListener( 'DOMContentLoaded', () => {
1515
const text = cell.textContent.trim();
1616

1717
if ( ( text.startsWith( 'http://' ) || text.startsWith( 'https://' ) ) && text.includes( '/wp-content/uploads/' ) ) {
18-
const link = document.createElement( 'a' );
19-
link.href = text;
20-
link.target = '_blank';
21-
link.rel = 'noopener noreferrer';
22-
link.textContent = 'View Recording';
23-
24-
cell.textContent = '';
25-
cell.appendChild( link );
26-
27-
cell.dataset.godamProcessed = '1';
18+
let url;
19+
20+
try {
21+
url = new URL( text, window.location.origin );
22+
} catch ( e ) {
23+
// If the URL is invalid, do not transform the cell into a link.
24+
return;
25+
}
26+
27+
// Only allow same-origin http(s) URLs.
28+
if ( ( url.protocol === 'http:' || url.protocol === 'https:' ) && url.origin === window.location.origin ) {
29+
const link = document.createElement( 'a' );
30+
link.href = url.href;
31+
link.target = '_blank';
32+
link.rel = 'noopener noreferrer';
33+
link.textContent = 'View Recording';
34+
35+
cell.textContent = '';
36+
cell.appendChild( link );
37+
38+
cell.dataset.godamProcessed = '1';
39+
}
2840
}
2941
} );
3042
};

0 commit comments

Comments
 (0)