Skip to content
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

Handle quotation marks in section names #115

Merged
merged 7 commits into from Jul 7, 2014
Merged

Handle quotation marks in section names #115

merged 7 commits into from Jul 7, 2014

Conversation

johnsyweb
Copy link
Contributor

This bit me today when using https://github.com/boxen/puppet-git to add an alias to a local git config file.

As https://github.com/johnsyweb/puppetlabs-inifile/commit/41fc8bfbf5d62c7daa64f330b4300375fc2609fd demonstrates, the alias should have been added to the bottom of the existing [alias] section, but it was actually added to the end of the file.

To fix this I have "relaxed" the SECTION_REGEX to be simply:

/^\s*\[([^\]]*)\]\s*$/

Where all characters between the opening [ and the closing ] are be considered to form the section name.

Replace with `be true` and `be false` and make predicate return a
boolean.

> Methods that don't return a boolean, shouldn't end in a question mark.
-- https://github.com/bbatsov/ruby-style-guide#naming
The section name appears on a line by itself, in square brackets (`[` and
`]`), all characters between the opening `[` and the closing `]` should
be considered to form the section name.
…ction-names

This should fix the build.

If this change isn't desired,
./spec/unit/puppet/provider/ini_setting/ruby_spec.rb:1044 could be
changed to:

```ruby
provider.exists?.should be_nil
```
@salamagd
Copy link

👍

1 similar comment
@nibalizer
Copy link

+1

Verifying that this PR addresses #98
Ini_file module does not recognize section names with forward slashes in them

https://tickets.puppetlabs.com/browse/MODULES-1194
@@ -5,7 +5,7 @@ module Puppet
module Util
class IniFile

@@SECTION_REGEX = /^\s*\[([\w\d\.\\\/\-\:\s]*[\w\d\.\\\/\-])\]\s*$/
@@SECTION_REGEX = /^\s*\[([^\]]*)\]\s*$/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on some similar discussion around this from #4 (diff) , one example concerning non-sections that I came up with was

[something "long"://aoeu1234]
[key] = value[aoeu]

And it matches correctly :). So +1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know of a case when a [ would begin a key and not be closed (and which a ] would then have to occur in the value).

Should we exclude = from the section titles? Like [^\]=]*

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. We could add a spec for

[something "long"://aoeu1234]
[key] = value[aoeu]

I can't think of a good reason to exclude = from section names. As long as the section name appears on a line by itself, in square brackets, I think we're good.

The only other character I could think of that we may wish to exclude is [, but couldn't find a sensible example as a test case.

hunner added a commit that referenced this pull request Jul 7, 2014
…ion-names

Handle quotation marks in section names
@hunner hunner merged commit 09b574e into puppetlabs:master Jul 7, 2014
awaxa pushed a commit to awaxa/awaxa-boxen that referenced this pull request Sep 7, 2014
This supported bugfix release corrects the inifile section header detection regex (so you can use more characters in your section titles).

More details: puppetlabs/puppetlabs-inifile#115
@johnsyweb johnsyweb deleted the handle-quotation-marks-in-section-names branch November 6, 2014 22:40
kortina pushed a commit to kortina/our-boxen that referenced this pull request Jan 29, 2015
This supported bugfix release corrects the inifile section header detection regex (so you can use more characters in your section titles).

More details: puppetlabs/puppetlabs-inifile#115
cegeka-jenkins pushed a commit to cegeka/puppet-inifile that referenced this pull request Oct 23, 2017
…ks-in-section-names

Handle quotation marks in section names
@smortex smortex added the bugfix label Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants