Skip to content

Commit

Permalink
Merge remote-tracking branch 'amazingpp/gh-193'
Browse files Browse the repository at this point in the history
* amazingpp/gh-193:
  Fix UnicodeEncodeError in `zkg create` with non-ASCII characters in user vars
  • Loading branch information
timwoj committed Sep 10, 2024
2 parents da77d8f + c6d2ef3 commit fd29b19
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
3.0.1-41 | 2024-09-10 10:36:13 +0200

* Fix UnicodeEncodeError in `zkg create` with non-ASCII characters in user vars (Fupeng Zhao)

3.0.1-39 | 2024-07-18 18:48:44 +0200

* Use documented Git package exception API (Benjamin Bannier, Corelight)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.1-39
3.0.1-41
2 changes: 1 addition & 1 deletion doc/man/zkg.1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "ZKG" "1" "May 13, 2024" "3.0.1-33" "Zeek Package Manager"
.TH "ZKG" "1" "Sep 10, 2024" "3.0.1-41" "Zeek Package Manager"
.SH NAME
zkg \- Zeek Package Manager
.sp
Expand Down
1 change: 1 addition & 0 deletions testing/baselines/tests.template-create/output
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
<...>/out3 (installed: master) - TODO: A more detailed description of test3.
error: could not determine value of user variable "name", provide via environment or --user-var
error: the following features are unknown: "doesntexist". Template "foo" offers "readme".
"foo" will use value of "name" (the name of the package, e.g. "FooBar") from command line: 你こ안مγПनสXש😊©GBCDČM
4 changes: 4 additions & 0 deletions testing/tests/template-create
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@
# Request an unknown feature. This should fail.
# @TEST-EXEC-FAIL: zkg create --packagedir out5 --template $TEMPLATES/foo --feature doesntexist >>output 2>&1

# Provide non-ASCII characters variable via --user-var and ensure resulting package installs
# @TEST-EXEC: zkg create --packagedir out6 --template $TEMPLATES/foo --user-var name=你こ안مγПनสXש😊©GBCDČM >>output
# @TEST-EXEC: zkg install ./out6

# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output
2 changes: 1 addition & 1 deletion zeekpkg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import logging

__version__ = "3.0.1-39"
__version__ = "3.0.1-41"
__all__ = ["manager", "package", "source", "template", "uservar"] # noqa: F405

LOG = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions zeekpkg/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,8 @@ def _replace(self, tmpl, content):
for name, val in tmpl.params().items():
pat = "@" + name + "@"
if not isinstance(content, str):
pat = bytes(pat, "ascii")
val = bytes(val, "ascii")
pat = bytes(pat, "utf-8")
val = bytes(val, "utf-8")
content = re.sub(pat, val, content, flags=re.IGNORECASE)

return content
Expand Down

0 comments on commit fd29b19

Please sign in to comment.