From e63c111c032fc16a29bb400ff42e9649a22ae7fc Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Mon, 24 Oct 2022 08:06:39 -0400 Subject: [PATCH] Escape special characters in resolved content base path (#9650) * Refactor * Escape special characters in the content pattern base path * Update changelog --- CHANGELOG.md | 4 +++- src/lib/content.js | 15 ++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b60a8520d7f9..5cd35ec99b4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing yet! +### Fixed + +- Escape special characters in resolved content base paths ([#9650](https://github.com/tailwindlabs/tailwindcss/pull/9650)) ## [3.2.1] - 2022-10-21 diff --git a/src/lib/content.js b/src/lib/content.js index 708bb687bb08..c486a6886374 100644 --- a/src/lib/content.js +++ b/src/lib/content.js @@ -94,17 +94,18 @@ function parseFilePath(filePath, ignore) { * @returns {ContentPath} */ function resolveGlobPattern(contentPath) { - contentPath.pattern = contentPath.glob - ? `${contentPath.base}/${contentPath.glob}` - : contentPath.base - - contentPath.pattern = contentPath.ignore ? `!${contentPath.pattern}` : contentPath.pattern - // This is required for Windows support to properly pick up Glob paths. // Afaik, this technically shouldn't be needed but there's probably // some internal, direct path matching with a normalized path in // a package which can't handle mixed directory separators - contentPath.pattern = normalizePath(contentPath.pattern) + let base = normalizePath(contentPath.base) + + // If the user's file path contains any special characters (like parens) for instance fast-glob + // is like "OOOH SHINY" and treats them as such. So we have to escape the base path to fix this + base = fastGlob.escapePath(base) + + contentPath.pattern = contentPath.glob ? `${base}/${contentPath.glob}` : base + contentPath.pattern = contentPath.ignore ? `!${contentPath.pattern}` : contentPath.pattern return contentPath }