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
Encode filepaths to be safe for Windows #489
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
return sb.toString(); | ||
} | ||
|
||
/** The inverse of {@link #encodePath(String)} */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, this function is not really the inverse of encodePath
, as it decodes anything, not only the chars that encodePath
encodes. So one can decode (66)(6f)(6f).text
as foo.txt
which cannot be generated by encodePath
. But I'm being pedantic and I think it's fine that it decodes anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Although, I'm actually getting rid of this altogether; this method isn't used anywhere.
// https://stackoverflow.com/questions/2678551/when-should-space-be-encoded-to-plus-or-20#:~:text=%20%20is%20a%20valid%20way,encodeURIComponent()%20does%20in%20JavaScript.) | ||
return ret.replace("+", "%20") | ||
val ret = URI(null, null, this, null) | ||
return ret.toString().replace("/", "%2F") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the change here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous implementation was encoding parentheses in percent encoding.
a1a636a
to
2b56fbe
Compare
Only encode characters that are strictly necessary in URI paths. This removes encoding for parentheses, for example.
63d4986
to
1ee4e2a
Compare
This changes the file paths to use characters that are safe for Windows. Channges the output of the following: * Package cache directory * Generated pkl-doc files * Kotlin generated code Unsafe characters are encoded as (<hex>). For example, the colon character `:` is encoded as `(3a)`. Additionally, this changes the cache directory prefix (package-1 to package-2). Follows the design of apple/pkl-evolution#3
1ee4e2a
to
de4d78b
Compare
Also: don't URI-encode parentheses in pkldoc.
Implementation for SPICE-0003