Originally created by @Valentin-Rault on GitHub (Dec 17, 2024).
Context:
I am generating a .properties file but the characters ":" and "=" are being escaped.
Example:
class Default {
project: String
fixed url = "https://domain.name.com
}
token = read("env:TOKEN") // TOKEN is a string that can contain the mentioned characters
defaults = new Default {
project = "some-project"
}
The generated default.properties file looks like this
I am expecting the token and url to not escape the characters.
Originally created by @Valentin-Rault on GitHub (Dec 17, 2024).
Context:
I am generating a .properties file but the characters ":" and "=" are being escaped.
Example:
```
class Default {
project: String
fixed url = "https://domain.name.com
}
token = read("env:TOKEN") // TOKEN is a string that can contain the mentioned characters
defaults = new Default {
project = "some-project"
}
```
The generated default.properties file looks like this
```
token = some\=randomtokenreadfromtheenv
project = some-project
url = https\://domain.name.com
```
I am expecting the token and url to not escape the characters.
Pkl's renderers always aim to render according to a format's standards. If you look at the documentation for java.util.Properties::store (here) it says:
The key and element characters #, !, =, and : are written with a preceding backslash to ensure that they are properly loaded.
And, indeed, if you load the generated .properties file, the result is as expected:
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
public class Test {
public static void main(String[] args) {
Properties appProps = new Properties();
try {
appProps.load(new FileInputStream("/path/to/test.properties"));
System.out.println(appProps);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Why is it important for you that it does not escape?
@holzensp commented on GitHub (Dec 18, 2024):
Pkl's renderers always aim to render according to a format's standards. If you look at the documentation for [`java.util.Properties::store` (here)](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Properties.html#store(java.io.Writer,java.lang.String)) it says:
> The key and element characters `#`, `!`, `=`, and `:` are written with a preceding backslash to ensure that they are properly loaded.
And, indeed, if you load the generated `.properties` file, the result is as expected:
```
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
public class Test {
public static void main(String[] args) {
Properties appProps = new Properties();
try {
appProps.load(new FileInputStream("/path/to/test.properties"));
System.out.println(appProps);
} catch (IOException e) {
e.printStackTrace();
}
}
}
```
produces
```
{project=some-project, url=https://domain.name.com, token=some=randomtokenreadfromtheenv}
```
Why is it important for you that it does _not_ escape?
@Valentin-Rault commented on GitHub (Dec 18, 2024):
I am attempting to generate multiple sentry.properties files for our CI as we have multiple projects. I might have been trying to fix an issue that isn't there by trying to not have it escape.
The generated sentry.properties file that was generated by their wizard does not escape those characters and therefore I was trying to achieve the same result when generating it with PKL.
I will have more insights after building my app with Xcode, there I will be able to see if the token and url are being loaded correctly.
I will post a message on this issue once this is done.
Thank you for the clarifying message.
@Valentin-Rault commented on GitHub (Dec 18, 2024):
I am attempting to generate multiple sentry.properties files for our CI as we have multiple projects. I might have been trying to fix an issue that isn't there by trying to not have it escape.
The generated sentry.properties file that was generated by their wizard does not escape those characters and therefore I was trying to achieve the same result when generating it with PKL.
I will have more insights after building my app with Xcode, there I will be able to see if the token and url are being loaded correctly.
I will post a message on this issue once this is done.
Thank you for the clarifying message.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @Valentin-Rault on GitHub (Dec 17, 2024).
Context:
I am generating a .properties file but the characters ":" and "=" are being escaped.
Example:
The generated default.properties file looks like this
I am expecting the token and url to not escape the characters.
@holzensp commented on GitHub (Dec 18, 2024):
Pkl's renderers always aim to render according to a format's standards. If you look at the documentation for
java.util.Properties::store(here) it says:And, indeed, if you load the generated
.propertiesfile, the result is as expected:produces
Why is it important for you that it does not escape?
@Valentin-Rault commented on GitHub (Dec 18, 2024):
I am attempting to generate multiple sentry.properties files for our CI as we have multiple projects. I might have been trying to fix an issue that isn't there by trying to not have it escape.
The generated sentry.properties file that was generated by their wizard does not escape those characters and therefore I was trying to achieve the same result when generating it with PKL.
I will have more insights after building my app with Xcode, there I will be able to see if the token and url are being loaded correctly.
I will post a message on this issue once this is done.
Thank you for the clarifying message.
@Valentin-Rault commented on GitHub (Dec 20, 2024):
Indeed it looks like the token and url are being loaded correctly. Thank you for the clarification
@bioball commented on GitHub (Dec 23, 2024):
Closing this as resolved. Please let us know if there's any more questions here.