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

Section headers with '.' in them are split #60

Closed
ankon opened this issue Jul 18, 2016 · 8 comments
Closed

Section headers with '.' in them are split #60

ankon opened this issue Jul 18, 2016 · 8 comments

Comments

@ankon
Copy link

ankon commented Jul 18, 2016

I have the following .ini file:

[https://www.example.com]
settingA = foo
settingB = bar

When parsing this .ini the resulting structure has the section header cut into pieces, I expected {'https://www.example.com': { settingA: 'foo', settingB: 'bar' } }, but got {'https://www': { 'example': { 'com': { settingA: 'foo', settingB: 'bar' } } } }.

@ankon
Copy link
Author

ankon commented Jul 18, 2016

Reading through the test directory it seems this is a feature, not a bug. Maybe it would be worthwhile to be more explicit about it in the documentation, especially also how to try to escape the values (the source of the .ini file seems to actually be happy with me escaping the '.' characters using a '').

@platinumazure
Copy link
Contributor

platinumazure commented Feb 28, 2018

For what it's worth, I'm working on a PR for this, but it will be a few days or weeks before I submit it.

The intended approach is to add a sectionDelimiter option which is . by default, but which could be set to another character or null in order to change the behavior accordingly.

@alex-shamshurin
Copy link

It's really very important:

[my.site.com]
user=admin
password=mypassword

@BamButz
Copy link

BamButz commented Jan 10, 2020

What's the status on this? I would also need the functionality to skip the splitting.

@ext
Copy link

ext commented Apr 18, 2020

I've hit this bug as well, I would be fine with a way to disable splitting instead of changing the delimiter but as it is right now this is preventing me from using this library but I cant find any other useful ini parser either.

@rehanvdm
Copy link

Just post process the data, I provided a solution here #22 (comment) (can probably be improved but it works. I don't foresee the creators of the package changing it anytime soon they are strictly following the ini specification.

@rquadling
Copy link
Contributor

Carrying on from @rehanvdm's comment, Section Nesting, it would seem every symbol in a URL is bad for this as all of them have been used to infer a hierarchy. Which is sort of true (https://github.com/npm/ini/issues/60 contains a hierarchy of information ... if you want to read it that way).

So, whilst the soft standard allows for these symbols, having the option to use a nominated symbol for the hierarchical sections or the ability to disable the hierarchical sections seem to be the only 2 options.

@wraithgar
Copy link
Member

There was a PR that attempted to address this but it had some unanswered questions in it.

If folks want to take a run at introducing a new option to set this delimiter, or disable the behavior altogether they are welcome to.

As of now folks can escape those strings like ini would if it were serializing the object itself.

> ini.encode({'http:example.net': { dots: true } })
'[http:example\\.net]\ndots=true\n'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants