mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 23:33:31 +00:00
[CSA-28] Use path normalization in API requests (#4580)
* Use path normalization in API requests * Remove CLI webpack config change that's unneeded * Add additional tests
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
/* eslint-disable no-useless-escape */
|
||||
import * as path from "path";
|
||||
|
||||
import { getHostname, parse } from "tldts";
|
||||
import { Merge } from "type-fest";
|
||||
|
||||
@@ -498,6 +500,15 @@ export class Utils {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a path for defense against attacks like traversals
|
||||
* @param denormalizedPath
|
||||
* @returns
|
||||
*/
|
||||
static normalizePath(denormalizedPath: string): string {
|
||||
return path.normalize(decodeURIComponent(denormalizedPath)).replace(/^(\.\.(\/|\\|$))+/, "");
|
||||
}
|
||||
|
||||
private static isMobile(win: Window) {
|
||||
let mobile = false;
|
||||
((a) => {
|
||||
|
||||
Reference in New Issue
Block a user