New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file names with closing braces in their name. #946

Merged
merged 4 commits into from Nov 7, 2015

Conversation

Projects
None yet
2 participants
@iwonbigbro
Contributor

iwonbigbro commented Jun 23, 2015

Fixes #945

iwonbigbro added some commits Jun 23, 2015

Produce something that works in all cases
I have been testing this escaping all morning on various combinations of file names.  In any single case, the original escaping algorithm works just fine, but in the case you have a file name containing a multitude of glob characters, you can't escape them if the file also contains spaces in the name.  In order to escape the glob characters, the file name can't be quoted (or at least that's the case with the version of rpmbuild I have).  The result is file not found errors.  In the end, the only solution that works consistently with all scenarios I have tested it with, is to replace the spaces with a single glob character match `?`, then escape any other glob characters present in the file name.
name = name.gsub("?", "[?]")
name = name.gsub("%", "[%]")
name = name.gsub(/(\ |\[|\]|\*|\?|\%|\$)/, {
' ' => '?',

This comment has been minimized.

@jordansissel

jordansissel Jun 25, 2015

Owner

This isn't correct, I don't think. Two files: 'foo bar' and 'foo.bar' will be matched by the result of this.

I'm not really sure what the right solution here is given rpmbuild's bugs with quoted strings and wildcards.

This comment has been minimized.

@iwonbigbro

iwonbigbro Jun 25, 2015

Contributor

Perhaps we need an option to explicitly define the behavior. But for me, in
mode -t dir, I would expect it to be harmless if it did match both "foo
bar" and "foo.bar". I've made the changes locally, so I'm happy with the
behavior. But it is really broken without the merge request if you have a
file named "foo [*baz%] bar". The quoting of the name stops the glob
expressions from working.

On Thu, 25 Jun 2015 17:28 Jordan Sissel notifications@github.com wrote:

In lib/fpm/package/rpm.rb
#946 (comment):

@@ -163,11 +163,15 @@ class FPM::Package::RPM < FPM::Package

Replace ? with [?] to make rpm not use globs

Replace % with [%] to make rpm not expand macros

def rpm_fix_name(name)

  • name = ""#{name}"" if name[/\s/]
  • name = name.gsub("[", "[[]")
  • name = name.gsub("", "[]")
  • name = name.gsub("?", "[?]")
  • name = name.gsub("%", "[%]")
  • name = name.gsub(/(\ |[|]|*|?|%|$)/, {
  •  ' ' => '?',
    

This isn't correct, I don't think. Two files: 'foo bar' and 'foo.bar' will
be matched by the result of this.

I'm not really sure what the right solution here is given rpmbuild's bugs
with quoted strings and wildcards.


Reply to this email directly or view it on GitHub
https://github.com/jordansissel/fpm/pull/946/files#r33274683.

@jordansissel

This comment has been minimized.

Owner

jordansissel commented Nov 7, 2015

Hmm, I suppose we could try this merge and see how folks are affected. I don't know if anyone would necessarily be broken by this change. We can revert or revisit it if it causes problems.

Thank you for this patch! LGTM

jordansissel added a commit that referenced this pull request Nov 7, 2015

Merge pull request #946 from iwonbigbro/master
Fix file names with closing braces in their name.

@jordansissel jordansissel merged commit 9dc3760 into jordansissel:master Nov 7, 2015

jordansissel added a commit that referenced this pull request Jun 20, 2016

Merge pull request #946 from iwonbigbro/master
Fix file names with closing braces in their name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment