Fix security related problems (#1522)

* Remove unnecessary capture group from regex

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>

* Rename component to make name more expressive

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>

* Remove redundant expression

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>

* Filter vbscript links

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>

* Remove superfluous parameter

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>

* Check if handler is set

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>

* Fix doc

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2021-10-01 22:51:57 +02:00 committed by GitHub
parent 0e512531a0
commit 87d6285da5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 17 additions and 11 deletions

View file

@ -15,9 +15,12 @@ interface RouteParameters {
id: string
}
export const Redirector: React.FC = () => {
/**
* Redirects the user to the editor if the link is a root level direct link to a version 1 note.
*/
export const NoteDirectLinkRedirector: React.FC = () => {
const { id } = useParams<RouteParameters>()
const [error, setError] = useState<boolean | null>(null)
const [error, setError] = useState<boolean | undefined>(undefined)
useEffect(() => {
getNote(id)
@ -25,9 +28,9 @@ export const Redirector: React.FC = () => {
.catch(() => setError(true))
}, [id])
if (error) {
if (error === true) {
return <NotFoundErrorScreen />
} else if (!error && error != null) {
} else if (error === false) {
return <Redirect to={`/n/${id}`} />
} else {
return <span>Loading</span>