Skip to content

Commit 9f7f5e8

Browse files
authored
Merge branch 'trunk' into stu-1971-in-app-browser-preview-may-keep-url-path-when-switching
2 parents eb3098d + ecfbf2d commit 9f7f5e8

11 files changed

Lines changed: 631 additions & 532 deletions

File tree

‎apps/local/src/index.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
import {
3535
arePathsEqual,
3636
isEmptyDir,
37+
isPathWithin,
3738
isWordPressDirectory,
3839
recursiveCopyDirectory,
3940
} from '@studio/common/lib/fs-utils';
@@ -525,7 +526,15 @@ export async function startLocalServer( options: LocalServerOptions ): Promise<
525526

526527
api.post( '/paths/compare', ( req: Request, res: Response ) => {
527528
const { path1, path2 } = req.body as { path1?: string; path2?: string };
528-
res.json( { equal: !! path1 && !! path2 && arePathsEqual( path1, path2 ) } );
529+
// Confine both operands to `sitesRoot`: nothing outside it can be a site, and
530+
// this keeps untrusted input from reaching statSync (in arePathsEqual).
531+
const equal =
532+
!! path1 &&
533+
!! path2 &&
534+
isPathWithin( sitesRoot, path1 ) &&
535+
isPathWithin( sitesRoot, path2 ) &&
536+
arePathsEqual( path1, path2 );
537+
res.json( { equal } );
529538
} );
530539

531540
api.post(

‎package-lock.json‎

Lines changed: 111 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)