-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development #254
Development #254
Conversation
export const AudioPreview = ({ src }: { src: string }) => ( | ||
<MediaThemeSutroAudio className="w-[70%] p-2 max-h-10"> | ||
{/* biome-ignore lint/a11y/useMediaCaption: by author */} | ||
<audio slot="media" src={src} playsInline crossOrigin="anonymous" /> |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
DOM text
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 1 day ago
To fix the problem, we need to ensure that the src
value is properly sanitized before being used in the audio
element. One effective way to do this is by using a library like DOMPurify
to sanitize the src
value. This will help prevent any malicious content from being executed.
- Import the
DOMPurify
library. - Sanitize the
src
value before using it in theaudio
element. - Ensure that the sanitized value is used consistently throughout the code.
-
Copy modified line R2 -
Copy modified lines R4-R12
@@ -1,8 +1,12 @@ | ||
import MediaThemeSutroAudio from 'player.style/sutro-audio/react'; | ||
import DOMPurify from 'dompurify'; | ||
|
||
export const AudioPreview = ({ src }: { src: string }) => ( | ||
<MediaThemeSutroAudio className="w-[70%] p-2 max-h-10"> | ||
{/* biome-ignore lint/a11y/useMediaCaption: by author */} | ||
<audio slot="media" src={src} playsInline crossOrigin="anonymous" /> | ||
</MediaThemeSutroAudio> | ||
); | ||
export const AudioPreview = ({ src }: { src: string }) => { | ||
const sanitizedSrc = DOMPurify.sanitize(src); | ||
return ( | ||
<MediaThemeSutroAudio className="w-[70%] p-2 max-h-10"> | ||
{/* biome-ignore lint/a11y/useMediaCaption: by author */} | ||
<audio slot="media" src={sanitizedSrc} playsInline crossOrigin="anonymous" /> | ||
</MediaThemeSutroAudio> | ||
); | ||
}; |
(imagePanZoom ? ( | ||
<ReactPanZoom image={source} alt={altName} imageClass={itemClassName} showButtons={showButtons} /> | ||
) : ( | ||
<img src={source} alt={altName} className={`${itemClassName} w-full h-full`} /> |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
DOM text
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 1 day ago
To fix the problem, we need to ensure that the source
variable is properly sanitized before being used in the src
attribute of the img
tag. One way to achieve this is by using a library like DOMPurify
to sanitize the URL. This will help prevent any malicious content from being executed.
- Install the
DOMPurify
library. - Import
DOMPurify
in the relevant file. - Use
DOMPurify
to sanitize thesource
variable before using it in thesrc
attribute.
-
Copy modified line R5 -
Copy modified line R26 -
Copy modified line R31 -
Copy modified line R33 -
Copy modified lines R35-R37
@@ -4,2 +4,3 @@ | ||
import ReactPanZoom from '~/modules/common/image-viewer'; | ||
import DOMPurify from 'dompurify'; | ||
|
||
@@ -24,2 +25,3 @@ | ||
}: AttachmentItemProps) => { | ||
const sanitizedSource = DOMPurify.sanitize(source); | ||
return ( | ||
@@ -28,9 +30,9 @@ | ||
(imagePanZoom ? ( | ||
<ReactPanZoom image={source} alt={altName} imageClass={itemClassName} showButtons={showButtons} /> | ||
<ReactPanZoom image={sanitizedSource} alt={altName} imageClass={itemClassName} showButtons={showButtons} /> | ||
) : ( | ||
<img src={source} alt={altName} className={`${itemClassName} w-full h-full`} /> | ||
<img src={sanitizedSource} alt={altName} className={`${itemClassName} w-full h-full`} /> | ||
))} | ||
{type.includes('audio') && <AudioPreview src={source} />} | ||
{type.includes('video') && <VideoPreview src={source} />} | ||
{type.includes('pdf') && <PreviewPDF file={source} />} | ||
{type.includes('audio') && <AudioPreview src={sanitizedSource} />} | ||
{type.includes('video') && <VideoPreview src={sanitizedSource} />} | ||
{type.includes('pdf') && <PreviewPDF file={sanitizedSource} />} | ||
</div> |
export const VideoPreview = ({ src }: { src: string }) => ( | ||
<MediaThemeSutro className="w-full p-4"> | ||
{/* biome-ignore lint/a11y/useMediaCaption: by author */} | ||
<video slot="media" src={src} playsInline crossOrigin="anonymous" /> |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
DOM text
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 1 day ago
To fix the problem, we need to ensure that the src
attribute is properly sanitized before being used in the video
element. This can be achieved by using a library like DOMPurify
to sanitize the URL. This will prevent any malicious content from being executed.
- Import the
DOMPurify
library. - Sanitize the
src
value before using it in thevideo
element. - Ensure that the sanitization is applied consistently wherever the
src
value is used.
-
Copy modified line R2 -
Copy modified lines R4-R12
@@ -1,8 +1,12 @@ | ||
import MediaThemeSutro from 'player.style/sutro/react'; | ||
import DOMPurify from 'dompurify'; | ||
|
||
export const VideoPreview = ({ src }: { src: string }) => ( | ||
<MediaThemeSutro className="w-full p-4"> | ||
{/* biome-ignore lint/a11y/useMediaCaption: by author */} | ||
<video slot="media" src={src} playsInline crossOrigin="anonymous" /> | ||
</MediaThemeSutro> | ||
); | ||
export const VideoPreview = ({ src }: { src: string }) => { | ||
const sanitizedSrc = DOMPurify.sanitize(src); | ||
return ( | ||
<MediaThemeSutro className="w-full p-4"> | ||
{/* biome-ignore lint/a11y/useMediaCaption: by author */} | ||
<video slot="media" src={sanitizedSrc} playsInline crossOrigin="anonymous" /> | ||
</MediaThemeSutro> | ||
); | ||
}; |
const imageElement = element.querySelector('img'); | ||
if (imageElement) { | ||
imageElement.onclick = onElClick; | ||
imageElement.setAttribute('src', url); |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
DOM text
const videoElement = element.querySelector('video'); | ||
if (videoElement) { | ||
videoElement.onclick = onElClick; | ||
videoElement.setAttribute('src', url); |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
DOM text
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 1 day ago
To fix the problem, we need to ensure that the url
obtained from the data-url
attribute is properly sanitized before being used as the src
attribute of the video
element. One way to achieve this is by using a library like DOMPurify
to sanitize the URL. This will help prevent any malicious content from being executed.
- Install the
DOMPurify
library. - Import
DOMPurify
in the file. - Use
DOMPurify
to sanitize theurl
before setting it as thesrc
attribute.
-
Copy modified line R4 -
Copy modified line R56
@@ -3,3 +3,3 @@ | ||
import { type Slides, openCarouselDialog } from '~/modules/common/carousel/carousel-dialog'; | ||
|
||
import DOMPurify from 'dompurify'; | ||
export const getContentAsString = (blocks: Block[]) => { | ||
@@ -55,3 +55,3 @@ | ||
for (const element of elementsWithDataUrl) { | ||
const url = element.getAttribute('data-url'); | ||
const url = DOMPurify.sanitize(element.getAttribute('data-url')); | ||
const contentType = element.getAttribute('data-content-type') || 'file'; |
const audioElement = element.querySelector('audio'); | ||
if (audioElement) { | ||
audioElement.onclick = onElClick; | ||
audioElement.setAttribute('src', url); |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
DOM text
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 1 day ago
To fix the problem, we need to ensure that the url
value is properly sanitized before it is used. One way to do this is to use a library like DOMPurify
to sanitize the URL. This will ensure that any potentially malicious content is removed before the URL is used in the setAttribute
method.
- Import the
DOMPurify
library. - Sanitize the
url
value before using it in thesetAttribute
method. - Ensure that the sanitized URL is used consistently across all relevant elements.
-
Copy modified line R4 -
Copy modified line R57
@@ -3,2 +3,3 @@ | ||
import { type Slides, openCarouselDialog } from '~/modules/common/carousel/carousel-dialog'; | ||
import DOMPurify from 'dompurify'; | ||
|
||
@@ -55,3 +56,3 @@ | ||
for (const element of elementsWithDataUrl) { | ||
const url = element.getAttribute('data-url'); | ||
const url = DOMPurify.sanitize(element.getAttribute('data-url')); | ||
const contentType = element.getAttribute('data-content-type') || 'file'; |
|
||
case 'file': { | ||
const fileLinkElement = document.createElement('a'); | ||
fileLinkElement.setAttribute('href', url); |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
DOM text
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 1 day ago
To fix the problem, we need to ensure that the url
value is properly sanitized or encoded before being used in the setAttribute
method. One way to achieve this is by using a library like DOMPurify
to sanitize the url
value. This will ensure that any potentially malicious content is removed before the url
is used.
- Install the
DOMPurify
library. - Import
DOMPurify
in the file. - Use
DOMPurify.sanitize
to sanitize theurl
value before using it in thesetAttribute
method.
-
Copy modified line R4 -
Copy modified line R56
@@ -3,3 +3,3 @@ | ||
import { type Slides, openCarouselDialog } from '~/modules/common/carousel/carousel-dialog'; | ||
|
||
import DOMPurify from 'dompurify'; | ||
export const getContentAsString = (blocks: Block[]) => { | ||
@@ -55,3 +55,3 @@ | ||
for (const element of elementsWithDataUrl) { | ||
const url = element.getAttribute('data-url'); | ||
const url = DOMPurify.sanitize(element.getAttribute('data-url')); | ||
const contentType = element.getAttribute('data-content-type') || 'file'; |
Pr branch 1731080247722
* feat: Electric proxy * + * fix: Fix electric proxy
No description provided.