-
Notifications
You must be signed in to change notification settings - Fork 120
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
Parse \/ correctly when input json #294
base: master
Are you sure you want to change the base?
Conversation
1 similar comment
@@ -239,6 +239,7 @@ class ConfigParser(object): | |||
'\\#': '#', | |||
'\\!': '!', | |||
'\\"': '"', | |||
'\/': '/', |
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.
Should it be \\/
instead? Do you have an example where you use it?
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.
As shown in #293 , json use \/
in unix path string like {"path":"\/var"}
.
pyhocon does not parse it correctly as jq does.
# echo '{"path":"\/var"}' | jq .
{
"path": "/var"
}
# echo '{"path":"\/var"}' | pyhocon
{
"path": "\\/var"
}
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.
Python handles \
in a strange way. '\/'
, '\\/'
, "\/"
and "\\/"
all work.
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('\/')
\/
>>> print("\/")
\/
>>> print("\\/")
\/
>>> print('\\/')
\/
>>> '\/var'.replace('\/','/')
'/var'
>>> '\/var'.replace('\\/','/')
'/var'
>>> '\/var'.replace("\/",'/')
'/var'
>>> '\/var'.replace("\\/",'/')
'/var'
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.
This syntax is described in RFC 8259 Section 7 Strings
#293
It seems not difficult to fix. But don' know side effect.