fog / fog-openstack

Fog for OpenStack Platform
MIT License
68 stars 130 forks source link

Fix `OpenStack.escape` with dash/extra characters #526

Open tokengeek opened 2 years ago

tokengeek commented 2 years ago

There is a bug in the regexp used in OpenStack.escape in that when extra_exclude_chars is set, dash is no longer the last character in the pattern.

This causes the regexp to treat it as a range, not a character of its own and that causes it to be escaped.

# Before
Fog::OpenStack.escape("test-pattern/", "/") # => "test%2Dpattern/"
Fog::OpenStack.escape("test-pattern/") # => "test-pattern%2F"
# After
Fog::OpenStack.escape("test-pattern/", "/") # => "test-pattern/"

It does not happen when extra_exclude_chars is blank.

We spotted this in our Brightbox provider which was forked from the OpenStack implementation. It appears to have been fixed in Rackspace for a few years and copied into Google provider.