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.
Enable shell-like glob escaping in %files
This was already partially implemented using rpmIsGlob() which interprets the backslash as an escape character, we just need to make sure any such characters are discarded as soon as they've been consumed, i.e. before the file name is passed to lstat(2) via addFile(). Support for literal (i.e. escaped) backslash is included. 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 have an rpmIsGlob() check when processing special directories like %doc, so add that. Fixes: rpm-software-management#1749
- Loading branch information
Showing
6 changed files
with
150 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# 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' | ||
|
||
# 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 | ||
|
||
# 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