From 3249c69c657476e08cab46e0cbe639c136d1f3d9 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Wed, 30 Nov 2022 10:37:22 -0500 Subject: [PATCH 1/2] Properly clip when there are too many `]` characters --- src/lib/defaultExtractor.js | 2 +- tests/default-extractor.test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/defaultExtractor.js b/src/lib/defaultExtractor.js index 15d27aca4348..b06c37e9eb52 100644 --- a/src/lib/defaultExtractor.js +++ b/src/lib/defaultExtractor.js @@ -184,7 +184,7 @@ function clipAtBalancedParens(input) { // This means that there was an extra closing `]` // We'll clip to just before it if (depth < 0) { - return input.substring(0, match.index) + return input.substring(0, match.index - 1) } // We've finished balancing the brackets but there still may be characters that can be included diff --git a/tests/default-extractor.test.js b/tests/default-extractor.test.js index e0a39431a0bc..e96b04bbb1f2 100644 --- a/tests/default-extractor.test.js +++ b/tests/default-extractor.test.js @@ -482,3 +482,9 @@ test('a lot of data', () => { expect(extractions).toContain(`underline`) }) + +test('ruby percent string array', () => { + let extractions = defaultExtractor('%w[text-[#bada55]]') + + expect(extractions).toContain(`text-[#bada55]`) +}) From f41284c15019fce71a99832591db77af2d204230 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Wed, 30 Nov 2022 10:39:59 -0500 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a450dc6b7200..ccf7e3ce1997 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add container queries plugin to standalone CLI ([#9865](https://github.com/tailwindlabs/tailwindcss/pull/9865)) - Support renaming of output files by `PostCSS` plugin. ([#9944](https://github.com/tailwindlabs/tailwindcss/pull/9944)) - Improve return value of `resolveConfig`, unwrap `ResolvableTo` ([#9972](https://github.com/tailwindlabs/tailwindcss/pull/9972)) +- Clip unbalanced brackets in arbitrary values ([#9973](https://github.com/tailwindlabs/tailwindcss/pull/9973)) ## [3.2.4] - 2022-11-11