Skip to content
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

feat: prevent special characters from url #1266

Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
protected emitEvents(): void {
const { all, extra } = this.parseUrlParams();
const metadata = this.createWireMetadata();
all.query = this.hasSpecialKeys(all.query);
this.$x.emit('ParamsLoadedFromUrl', all, metadata);
this.$x.emit('ExtraParamsLoadedFromUrl', extra, metadata);
// TODO: Move this logic from here.
Expand All @@ -165,6 +166,21 @@
this.urlLoaded = true;
}

/**
* Detects if the user typing or pasting special/forbidden characters in the URL query.
*
* @internal
* @param query - Query from the url that will be checked for special characters.
* @returns Query without special characters.
*/
protected hasSpecialKeys(query: string): string {
if (/[<>]/.test(query ?? '')) {
return query.replace(/<.*>/g, '');
Fixed Show fixed Hide fixed
} else {
return query;
}
}

/**
* Creates the wire metadata to include in every emitted {@link XEvent}.
*
Expand Down