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

Akka.NET's HOCON does not treat triple-quotes correctly. #1687

Closed
BrainSlugs83 opened this issue Feb 4, 2016 · 9 comments · Fixed by #1689
Closed

Akka.NET's HOCON does not treat triple-quotes correctly. #1687

BrainSlugs83 opened this issue Feb 4, 2016 · 9 comments · Fixed by #1689

Comments

@BrainSlugs83
Copy link

From the HOCON Readme:

If the three-character sequence """ appears, then all Unicode characters until a closing """ sequence are used unmodified to create a string value. Newlines and whitespace receive no special treatment. Unlike Scala, and unlike JSON quoted strings, Unicode escapes are not interpreted in triple-quoted strings.

The following code demonstrates the issue:

var str = @"blah\de-dah";
ConfigurationFactory.ParseString
(
    $"SomeValue = \"\"\"{str}\"\"\""
);

The actual contents of that string are evaluated to be:

SomeValue = """blah\de-dah"""

The runtime error I receive clearly shows that the HOCON parser is trying to read "\d" as an escape sequence instead of two literal unicode characters:

Unhandled Exception: System.NotSupportedException: Unknown escape code: d
at Akka.Configuration.Hocon.HoconTokenizer.PullEscapeSequence()
at Akka.Configuration.Hocon.HoconTokenizer.PullTripleQuotedText()
at Akka.Configuration.Hocon.HoconTokenizer.PullValue()
at Akka.Configuration.Hocon.Parser.ParseValue(HoconValue owner, String currentPath)
at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
at Akka.Configuration.Hocon.Parser.ParseText(String text, Func`2 includeCallback)
at Akka.Configuration.ConfigurationFactory.ParseString(String hocon)

@rogeralsing
Copy link
Contributor

I'll take a look at this one

@rogeralsing
Copy link
Contributor

PR #1689

@BrainSlugs83
Copy link
Author

Thanks, Roger!

Horusiath added a commit that referenced this issue Feb 7, 2016
@Danthar
Copy link
Member

Danthar commented Apr 8, 2016

And its back, or i found another edge case

         ConfigurationFactory.ParseString
         (
                @"SomeValue = ""Data Source=C:\Dev\MyApp\bin\Debug\journal-db.db; Version=3;"""
         );

Notes: Manually escaping the slashes again, works. So thats a workaround.

@Danthar Danthar reopened this Apr 8, 2016
@rogeralsing
Copy link
Contributor

There are no tripplequotes in that example """ ?

Skickat från min iPhone

8 apr. 2016 kl. 11:11 skrev Arjen Smits [email protected]:

And its back, or i found another edge case

ConfigurationFactory.ParseString
(
$"SomeValue = ""Data Source=C:\Dev\MyApp\bin\Debug\journal-db.db; Version=3;""
);

You are receiving this because you were assigned.
Reply to this email directly or view it on GitHub

@Danthar
Copy link
Member

Danthar commented Apr 8, 2016

After re-reading the hocon spec. I realised its actually correct behavior. Its just not how i expected it to work. The point is, if you build a filepath string in code with path.combine or whatnot. And pass that in a hocon variable. It throws with Unknown escape code: <something> because it parses the single \ as an escape sequence.
I expected it to handle file-paths transparently. But it doesn't

@rogeralsing
Copy link
Contributor

https://github.com/akkadotnet/akka.net/blob/dev/src/core/Akka.Tests/Configuration/HoconTests.cs#L392

There is a test verifying that tripplequotes can be parsed.
We should add a case for the failing string too

@Danthar
Copy link
Member

Danthar commented Apr 8, 2016

Ill add a testcase

@Danthar
Copy link
Member

Danthar commented Apr 11, 2016

Additional testcase merged

@Danthar Danthar closed this as completed Apr 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants