-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib.generators.toPlist: escape XML syntax in strings & keys
Before this patch, code like this would break generate invalid XML: lib.generators.toPlist {} "ab<cd" That's obviously bad, since the call to toPlist often happens through indirection, as is the case in e.g. the nix-darwin project. A user might not realize that they have to escape the strings. This patch adds the argument 'escape' to lib.generators.plist and emits a warning if it is not set to true. In a future release, this behavior should become the default.
- Loading branch information
Showing
4 changed files
with
93 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>nested</key> | ||
<dict> | ||
<key>values</key> | ||
<dict> | ||
<key>attrs</key> | ||
<dict> | ||
<key>foo b/ar</key> | ||
<string>baz</string> | ||
</dict> | ||
<key>bool</key> | ||
<true/> | ||
<key>emptyattrs</key> | ||
<dict> | ||
|
||
</dict> | ||
<key>emptylist</key> | ||
<array> | ||
|
||
</array> | ||
<key>emptystring</key> | ||
<string></string> | ||
<key>float</key> | ||
<real>0.133700</real> | ||
<key>int</key> | ||
<integer>42</integer> | ||
<key>keys are <escaped></key> | ||
<string>and < so are string values</string> | ||
<key>list</key> | ||
<array> | ||
<integer>3</integer> | ||
<integer>4</integer> | ||
<string>test</string> | ||
</array> | ||
<key>newlinestring</key> | ||
<string> | ||
</string> | ||
<key>path</key> | ||
<string>/foo</string> | ||
<key>string</key> | ||
<string>fn${o}"r\d</string> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters