Skip to content

Commit

Permalink
fix: incomplete url substring sanitization
Browse files Browse the repository at this point in the history
  • Loading branch information
Calvin Rohloff committed Sep 18, 2024
1 parent 836a056 commit 273003e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/renderer/hooks/useGif.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { useEffect, useState } from 'react';
import { TenorFetchResult, TenorGif } from '../../main/utils/tenor';

const allowedHosts = ['tenor.com', 'www.tenor.com'];

export default function useGif(url: string): TenorGif | null {
const [gif, setGif] = useState<TenorGif | null>(null);

useEffect(() => {
if (!url.startsWith('https://tenor.com')) {
const uri = new URL(url);

if (allowedHosts.includes(uri.host.toLowerCase())) {
setGif(null);
return;
}
Expand Down

0 comments on commit 273003e

Please sign in to comment.