Skip to content

Commit 2023384

Browse files
committed
fix DISPLAY=unix:[0-9]+ parsing
1 parent 2020f0a commit 2023384

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎x11rb-protocol/src/parse_display/connect_instruction.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ mod tests {
9797
assert_eq!(ci, vec![ConnectAddress::Socket("/tmp/.X11-unix/X0".into())]);
9898
}
9999

100+
#[test]
101+
fn try_over_unix_display() {
102+
let pd = parse_display_with_file_exists_callback("unix:11.0", |_| false).unwrap();
103+
let ci = pd.connect_instruction();
104+
let ci = ci.collect::<Vec<_>>();
105+
106+
assert_eq!(ci, vec![ConnectAddress::Socket("/tmp/.X11-unix/X11".into())]);
107+
}
108+
100109
#[test]
101110
fn try_over_unix_socket_path() {
102111
const SOCKET_PATH: &str = "/path/to/socket";

‎x11rb-protocol/src/parse_display/mod.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ pub fn parse_display_with_file_exists_callback(
7373
return parse_display_direct_path(dpy_name, file_exists);
7474
}
7575
if let Some(remaining) = dpy_name.strip_prefix("unix:") {
76-
return parse_display_direct_path(remaining, file_exists);
76+
if let Ok(display) = parse_display_direct_path(remaining, &file_exists) {
77+
return Ok(display);
78+
}
7779
}
7880

7981
// Everything up to the last '/' is the protocol. This part is optional.

0 commit comments

Comments
 (0)