-
Notifications
You must be signed in to change notification settings - Fork 177
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
Handle quotation marks in section names #115
Conversation
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 ```
👍 |
1 similar comment
+1 |
Verifying that this PR addresses #98
…rks-in-section-names
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*$/ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 [^\]=]*
There was a problem hiding this comment.
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.
…ion-names Handle quotation marks in section names
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
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
…ks-in-section-names Handle quotation marks in section names
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.