Skip to content

[BUGFIX] Exclude directories whose name contains a slash - #106

Merged
bmack merged 1 commit into
TYPO3:mainfrom
CybotTM:bugfix/exclude-pattern-with-slash
Aug 31, 2026
Merged

[BUGFIX] Exclude directories whose name contains a slash#106
bmack merged 1 commit into
TYPO3:mainfrom
CybotTM:bugfix/exclude-pattern-with-slash

Conversation

@CybotTM

@CybotTM CybotTM commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

VersionService::createZipArchiveFromPath() builds its exclude patterns by interpolating each configured entry into a slash-delimited regular expression — '/^' . $excludeDirectory . '/i' for directories, '/' . $excludeFile . '$/i' for files. An entry containing a slash therefore closes the pattern early: Resources/Private/Build becomes /^Resources/Private/Build/i, which PHP reads as the pattern ^Resources followed by the modifiers Private…. It emits preg_match(): Unknown modifier 'P' once per inspected file and returns false, so the directory is packaged instead of skipped.

Observed on a real release: the job linked in #105 prints that warning a few hundred times, and the archive published from it carries 36 files below Resources/Private/Build/ — the directory its configuration excludes.

The fix quotes the configured entries. The README documents them as directory and file names, and conf/ExcludeFromPackaging.php contains no regular expressions, so the shipped defaults behave exactly as before: the file rule still matches a suffix, the directory rule still matches a prefix.

The added test packages a tree containing Resources/Private/Build/gulpfile.js and asserts the file is absent from the archive. Against the unpatched filter it fails with Failed asserting that an array does not contain 'Resources/Private/Build/gulpfile.js'; with the patch the full unit suite is green (153 tests) and composer cs reports no findings.

This is not the cause of #105. The HTTP 500 reported there comes from TER, not from tailor — the archive was accepted and the version record was written. This change only explains the warnings in the same log, so please do not close #105 with it.

Assisted by claude-code:claude-opus-5 — Session

The packaging filter interpolates every entry of the exclude
configuration straight into a slash-delimited regular expression, so an
entry naming a nested directory such as `Resources/Private/Build` ends
up as `/^Resources/Private/Build/i`. PHP reads that as the pattern
`^Resources` followed by the modifiers `Private...`, emits "Unknown
modifier 'P'" once per inspected file and returns false - so the
directory is packaged instead of skipped, and the published archive
carries the very sources the configuration excludes.

Quote the configured entries. They are documented as directory and file
names and the shipped default configuration contains no regular
expressions, so nothing that works today changes: the file rule still
matches a suffix, the directory rule still matches a prefix.

The regression test fails against the old filter with exactly the file
that should have been excluded.

Assisted-by: claude-code:claude-opus-5
Agent-Session: https://claude.ai/code/session_01JYQciiXoiApXBfcJrFMnA9
Agent-Host: 32116e
Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
@bmack
bmack merged commit ba7087d into TYPO3:main Aug 31, 2026
6 checks passed
@eliashaeussler

Copy link
Copy Markdown
Member

Hi @CybotTM @bmack, this is actually a breaking change. Some extensions out there already escape slashes in directory excludes to circumvent the described issue. However, with this change, the slash gets double-encoded and the exclude no longer works as expected.

See https://github.com/search?q=path%3Apackaging_exclude.php+-is%3Afork+%22%5C%5C%2F%22&type=code&p=1 for affected extensions.

We should either find a more stable solution (e.g. strip existing escapes off before doing preg_quote) or treat this change as breaking.

@mschwemer

Copy link
Copy Markdown

There must be some breaking change before this one, because the powermail release 13.2.0 was published on Aug. 3rd and was uploaded to TER without any problems.

Something some have changed inbetween, because I did not touch the code, causing the issue.

@CybotTM

CybotTM commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Something some have changed inbetween, because I did not touch the code, causing the issue.

The reason may be in the TER data, something in there made updating release info for your package stop working. Someone at TER needs to look into this.

@CybotTM

CybotTM commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Hi @eliashaeussler,

Some extensions out there already escape slashes in directory excludes to circumvent the described issue.

Thanks for the heads up.
We may just leave it as it is, and make escaping a requirement. But IMO the worst solution, as we bind internal processing knowledge/behaviour (regular expression delimiters) with external requirements.

We may unescape before escaping.

We may switch to different delimiters.

We may mark it as breaking change.

bmack added a commit that referenced this pull request Sep 1, 2026
Quoting the configured exclude entries (#106) broke the workaround
extensions used for nested directories: an entry written as
`Resources\/Private\/Build` was passed to preg_quote as is, so the
backslash itself got escaped and the resulting pattern only matched a
directory whose name literally contains a backslash. Those extensions
silently packaged the directory they excluded before.

Strip the escaped slashes before quoting, so both notations describe
the same directory and no extension configuration needs a change.
@CybotTM
CybotTM deleted the bugfix/exclude-pattern-with-slash branch September 2, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Exception while using in GH action

4 participants