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

values with quotes are not escaped properly #96

Closed
ethanlu opened this issue Sep 15, 2016 · 1 comment
Closed

values with quotes are not escaped properly #96

ethanlu opened this issue Sep 15, 2016 · 1 comment
Labels

Comments

@ethanlu
Copy link

ethanlu commented Sep 15, 2016

I had a configuration file where a property contained a piece of string that had a double quote in it, but pyhocon was not able to parse it correctly. Here is a breakdown of the issue:

if I have a configuration file like so:

// test.conf
{
    test {
        foo = abc"def
        bar = "abc\"def"
        foobar = "abc"def"
    }
}

parse it into Pyhocon and print out the values:

config = ConfigFactory.parse_file('test.conf')
print(config['test']['foo'])
print(config['test']['bar'])
print(config['test']['foobar'])

I get as output:

'abc"def'
'abc\\def"'
'abcdef"'

The first output is correct, but the second and third is not. This was done in Python 3.4.3 btw.

@darthbear
Copy link
Member

Sorry for the delay @ethanlu. This should be addressed in pyhocon==0.3.41.
In HOCON, only the followings are correct:

a = "abc\"test" => abc"test
b = "abc""cde" => abccde
c = abc\"cde => abc"cde

The followings are invalid:

a = abc"cde => This string is invalid because it starts as an unquoted string (abc) followed by a quoted string that doesn't end.
b = "abc"cde" => The first string is "abc" and the second one is starting as an unquoted string cde followed by an empty quoted string that doesn't end

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

No branches or pull requests

2 participants