Skip to content

Commit ee8fcf9

Browse files
committed
only valid unicode paths are accepted on windows
1 parent 2796f8f commit ee8fcf9

File tree

2 files changed

+2
-32
lines changed

2 files changed

+2
-32
lines changed

asyncgit/src/sync/hooks.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,6 @@ mod tests {
8787

8888
os_string.push("gitui $# ' ");
8989

90-
#[cfg(windows)]
91-
{
92-
use std::os::windows::ffi::OsStringExt;
93-
94-
const INVALID_UTF16: &[u16] = &[0xD83D];
95-
96-
os_string.push(OsString::from_wide(INVALID_UTF16));
97-
98-
assert!(os_string.to_str().is_none());
99-
}
10090
#[cfg(target_os = "linux")]
10191
{
10292
use std::os::unix::ffi::OsStrExt;

git2-hooks/src/hookspath.rs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use git2::Repository;
1+
use git2::{IntoCString, Repository};
22

33
use crate::{error::Result, HookResult, HooksError};
44

@@ -146,27 +146,7 @@ impl HookPaths {
146146
if let Some(hook) = hook.to_str() {
147147
os_str.push(hook.replace('\'', REPLACEMENT));
148148
} else {
149-
#[cfg(windows)]
150-
{
151-
use std::os::windows::ffi::{
152-
OsStrExt, OsStringExt,
153-
};
154-
155-
let mut new_str: Vec<u16> = vec![];
156-
157-
for ch in hook.as_os_str().encode_wide() {
158-
if ch == (b'\'' as u16) {
159-
new_str.extend(
160-
std::ffi::OsStr::new(REPLACEMENT)
161-
.encode_wide(),
162-
);
163-
} else {
164-
new_str.push(ch);
165-
}
166-
}
167-
168-
os_str.push(OsString::from_wide(&new_str));
169-
}
149+
return Err(HooksError::PathToString);
170150
}
171151
os_str.push("'");
172152
os_str.push(" \"$@\"");

0 commit comments

Comments
 (0)