Fix handling of file: module URIs with non-ASCII characters (#696)

Addresses an issue where Pkl cannot evaluate files with non-ASCII characters.
This commit is contained in:
Josh B
2024-10-23 20:52:40 -07:00
committed by GitHub
parent 5a654e453c
commit f9fe226eba
10 changed files with 121 additions and 9 deletions
@@ -0,0 +1,6 @@
// covers https://github.com/apple/pkl/issues/653
日本語 = "Japanese language"
readOne = read("日本語.pkl").text
readGlob = read*("./日*.pkl").keys
importOne = import("日本語.pkl").readOne
importGlob = import*("./日*.pkl").keys
@@ -0,0 +1,2 @@
// covers https://github.com/apple/pkl/issues/653
日本語 = throw("Error reporting should also handle unicode filenames!")
@@ -0,0 +1,21 @@
日本語 = "Japanese language"
readOne = """
// covers https://github.com/apple/pkl/issues/653
日本語 = "Japanese language"
readOne = read("日本語.pkl").text
readGlob = read*("./日*.pkl").keys
importOne = import("日本語.pkl").readOne
importGlob = import*("./日*.pkl").keys
"""
readGlob = Set("./日本語.pkl", "./日本語_error.pkl")
importOne = """
// covers https://github.com/apple/pkl/issues/653
日本語 = "Japanese language"
readOne = read("日本語.pkl").text
readGlob = read*("./日*.pkl").keys
importOne = import("日本語.pkl").readOne
importGlob = import*("./日*.pkl").keys
"""
importGlob = Set("./日本語.pkl", "./日本語_error.pkl")
@@ -0,0 +1,10 @@
–– Pkl Error ––
Error reporting should also handle unicode filenames!
x | 日本語 = throw("Error reporting should also handle unicode filenames!")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at 日本語_error#日本語 (file:///$snippetsDir/input/modules/%E6%97%A5%E6%9C%AC%E8%AA%9E_error.pkl)
xxx | text = renderer.renderDocument(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at pkl.base#Module.output.text (pkl:base)