Skip to content

Commit e63c111

Browse files
Escape special characters in resolved content base path (#9650)
* Refactor * Escape special characters in the content pattern base path * Update changelog
1 parent 547f9f6 commit e63c111

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Escape special characters in resolved content base paths ([#9650](https://github.com/tailwindlabs/tailwindcss/pull/9650))
1113

1214
## [3.2.1] - 2022-10-21
1315

src/lib/content.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,18 @@ function parseFilePath(filePath, ignore) {
9494
* @returns {ContentPath}
9595
*/
9696
function resolveGlobPattern(contentPath) {
97-
contentPath.pattern = contentPath.glob
98-
? `${contentPath.base}/${contentPath.glob}`
99-
: contentPath.base
100-
101-
contentPath.pattern = contentPath.ignore ? `!${contentPath.pattern}` : contentPath.pattern
102-
10397
// This is required for Windows support to properly pick up Glob paths.
10498
// Afaik, this technically shouldn't be needed but there's probably
10599
// some internal, direct path matching with a normalized path in
106100
// a package which can't handle mixed directory separators
107-
contentPath.pattern = normalizePath(contentPath.pattern)
101+
let base = normalizePath(contentPath.base)
102+
103+
// If the user's file path contains any special characters (like parens) for instance fast-glob
104+
// is like "OOOH SHINY" and treats them as such. So we have to escape the base path to fix this
105+
base = fastGlob.escapePath(base)
106+
107+
contentPath.pattern = contentPath.glob ? `${base}/${contentPath.glob}` : base
108+
contentPath.pattern = contentPath.ignore ? `!${contentPath.pattern}` : contentPath.pattern
108109

109110
return contentPath
110111
}

0 commit comments

Comments
 (0)