forked from rpm-software-management/rpm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for shell-like escaping in %files
Turn off the special meaning of glob characters within a file name if they're preceded by a backslash. This was already partially implemented using rpmIsGlob() which interprets the backslash as an escape character, we just need to make sure any backslashes are discarded as soon as they've been consumed, i.e. before the file name is passed to lstat(2) via addFile(), so that it actually works. Note that, while rpmGlob() understands escapes too, they're only applicable to spaces and quotes during string tokenization, not to globs, and changing its behavior would break the API, so we need to handle glob escapes separately. For this reason, we also need to use rpmIsGlob() when processing special directories like %doc, so do that. For curly braces specifically, we need to push the brace detection logic from rpmIsGlob() down to __glob_pattern_p() so that backslashes are also applicable to those. That's probably where it belongs, anyway. Since we're now passing it the flags directly, we need to make sure the behavior stays the same in the other few places where __glob_pattern_p() is called, by turning off the GLOB_BRACE flag there. This part is basically a revert of commit 630a097, although functionally equivalent. Fixes: rpm-software-management#1749
- Loading branch information
Showing
7 changed files
with
174 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# We need to hardcode the install prefix so that we can compare the %%doc | ||
# filenames in the resulting package (with "rpm -qpl") against a static list in | ||
# tests/rpmbuild.at. | ||
%global _prefix /opt | ||
|
||
Name: globesctest | ||
Version: 1.0 | ||
Release: 1 | ||
Summary: Testing file glob escape behavior | ||
Group: Testing | ||
License: GPL | ||
BuildArch: noarch | ||
|
||
%description | ||
%{summary}. | ||
|
||
|
||
%build | ||
touch 'foo[bar]' bar baz 'foo bar' | ||
|
||
%install | ||
mkdir -p %{buildroot}/opt | ||
|
||
# Glob escaping | ||
touch '%{buildroot}/opt/foo[bar]' | ||
touch '%{buildroot}/opt/foo[bar baz]' | ||
touch '%{buildroot}/opt/foo\[bar\]' | ||
touch '%{buildroot}/opt/foo*' | ||
touch '%{buildroot}/opt/foo\bar' | ||
touch %{buildroot}/opt/foo\\ | ||
touch '%{buildroot}/opt/foo?bar' | ||
touch '%{buildroot}/opt/foo{bar,baz}' | ||
|
||
# Regression checks | ||
touch '%{buildroot}/opt/foo-bar1' | ||
touch '%{buildroot}/opt/foo-bar2' | ||
touch '%{buildroot}/opt/fooxbarybaz' | ||
touch "%{buildroot}/opt/foo'baz" | ||
touch '%{buildroot}/opt/foobar' | ||
touch '%{buildroot}/opt/foobaz' | ||
touch '%{buildroot}/opt/foobara' | ||
touch '%{buildroot}/opt/foobarb' | ||
touch '%{buildroot}/opt/foobaza' | ||
touch '%{buildroot}/opt/foobazb' | ||
touch '%{buildroot}/opt/foobaya' | ||
touch '%{buildroot}/opt/foobayb' | ||
touch '%{buildroot}/opt/foobawa' | ||
touch '%{buildroot}/opt/foobawb' | ||
|
||
%files | ||
|
||
%doc foo\[bar\] ba* "foo bar" | ||
|
||
# Glob escaping | ||
/opt/foo\[bar\] | ||
"/opt/foo\[bar baz\]" | ||
/opt/foo\\\[bar\\\] | ||
/opt/foo\* | ||
/opt/foo\\bar | ||
/opt/foo\\ | ||
/opt/foo\?bar | ||
/opt/foo\{bar,baz\} | ||
|
||
# Regression checks | ||
/opt/foo-bar* | ||
/opt/foo?bar?baz | ||
/opt/foo'baz | ||
/opt/foo{bar,baz} | ||
/opt/foo{bar{a,b},baz{a,b}} | ||
/opt/foo{bay*,baw*} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters