mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-16 08:50:40 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac9606b872 | ||
|
|
4e91126561 |
No files matched your search
Generated
+1
-1
@@ -2804,7 +2804,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "uu-remote-linux"
|
||||
version = "0.2.54"
|
||||
version = "0.2.55"
|
||||
dependencies = [
|
||||
"ab_glyph",
|
||||
"async-trait",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "uu-remote-linux"
|
||||
version = "0.2.54"
|
||||
version = "0.2.55"
|
||||
edition = "2021"
|
||||
default-run = "uuremote-server"
|
||||
authors = ["uu-remote-linux contributors"]
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
修复版:Linux → Windows 文本剪贴板。/ Fix release: Linux → Windows text clipboard.
|
||||
|
||||
### 修复 / Fixed
|
||||
- **Windows 文本剪贴板(#200,修 #151)**:主机提供 Windows Unicode 文本(预定义格式 id 13)时不再附带格式名字段,避免 Windows 控制端把它注册成自定义格式、导致无法粘贴。Mac 格式名、UTF-16LE 编码、CRLF 与结尾 NUL 不变。/ The host now offers predefined Windows Unicode text (id 13) without a format name, so the Windows viewer no longer registers it as a custom format and standard paste works. Mac format names, UTF-16LE encoding, CRLF and the terminating NUL are unchanged.
|
||||
|
||||
感谢 @max2787 的贡献。/ Thanks to @max2787.
|
||||
|
||||
### 验证范围 / Validation
|
||||
单元测试与 CI;#200 作者在 Debian 13 / Xfce 上与官方 Windows 控制端实测双向复制粘贴(中文、多行、emoji)。维护方未做 Windows/Mac 客户端界面验收。
|
||||
|
||||
### 下载 / Download
|
||||
`uu-remote-linux_0.2.55_<amd64|arm64>.deb`,或 `uu-remote-linux-v0.2.55-<x86_64|aarch64>-linux.tar.gz`(解压后运行 `./install.sh`),或 `docker pull ghcr.io/vallierdev/uu-remote-linux:v0.2.55`(x86_64)。
|
||||
|
||||
**非官方项目,与网易无关。** / **Unofficial, not affiliated with NetEase.**
|
||||
+35
-6
@@ -17,9 +17,9 @@ impl TextFormat {
|
||||
}
|
||||
fn id(self)->u64{match self{Self::Windows=>UNICODE_TEXT,Self::Mac=>0}}
|
||||
fn name(self)->&'static str{match self{Self::Windows=>"CF_UNICODETEXT",Self::Mac=>MAC_TEXT}}
|
||||
/// Name in a format-list offer. Official Windows peers name predefined formats `predefined_<id>`; a plain
|
||||
/// `CF_UNICODETEXT` makes the Windows viewer register a custom format instead of id 13 (issue #151).
|
||||
fn offer_name(self)->&'static str{match self{Self::Windows=>WINDOWS_OFFER_NAME,Self::Mac=>MAC_TEXT}}
|
||||
/// Issue #151 reports that Windows registers even `predefined_13` as a custom format.
|
||||
/// Omit the name for predefined id 13; verified with the official Windows viewer on an X11 host.
|
||||
fn offer_name(self)->Option<&'static str>{match self{Self::Windows=>None,Self::Mac=>Some(MAC_TEXT)}}
|
||||
fn encode(self,text:&str)->Vec<u8>{match self{Self::Windows=>encode_windows(text),Self::Mac=>text.as_bytes().to_vec()}}
|
||||
fn decode(self,data:&[u8])->Result<String,&'static str>{
|
||||
match self{
|
||||
@@ -34,7 +34,6 @@ impl TextFormat {
|
||||
}
|
||||
}
|
||||
}
|
||||
const WINDOWS_OFFER_NAME:&str="predefined_13";
|
||||
const BLOCK_BYTES:usize=0x20000;
|
||||
const MAX_BYTES:usize=MAX_TEXT*2+2;
|
||||
pub struct ResultMessages {pub messages:Vec<(u32,Vec<u8>)>,pub text:Option<String>}
|
||||
@@ -100,7 +99,7 @@ impl State{
|
||||
if text.contains('\0')||encode_windows(&text).len()>MAX_BYTES{return Err("clipboard encoded text exceeds limit");}
|
||||
self.local=Some(text);
|
||||
let mut list=Vec::new();
|
||||
for kind in formats {let mut format=Vec::new();int(1,kind.id(),&mut format);string(2,kind.offer_name(),&mut format);nested(1,&format,&mut list);}
|
||||
for kind in formats {let mut format=Vec::new();int(1,kind.id(),&mut format);if let Some(name)=kind.offer_name(){string(2,name,&mut format);}nested(1,&format,&mut list);}
|
||||
Ok(request(id,1,&list))
|
||||
}
|
||||
pub fn request(&mut self,rpc:&[u8],next:&mut impl FnMut()->u64)->Result<ResultMessages,&'static str>{
|
||||
@@ -192,6 +191,36 @@ impl State{
|
||||
#[cfg(test)]
|
||||
mod tests{
|
||||
use super::*;
|
||||
#[test]
|
||||
fn windows_format_offer_omits_name_field_entirely(){
|
||||
for offer in [State::default().offer(42,"hi".into()).unwrap(),State::default().offer_any_host(42,"hi".into()).unwrap()]{
|
||||
assert_eq!(number(header(&offer).unwrap(),1),Ok(42));
|
||||
let list=bytes(bytes(&offer,9).unwrap().unwrap(),1).unwrap().unwrap();
|
||||
let formats=decode_wire(list).unwrap();
|
||||
let WireValue::Bytes(windows)=formats[0].value else{panic!("missing Windows format")};
|
||||
assert_eq!(windows,&[8,13]); // Only field 1: not even an empty field 2.
|
||||
assert!(decode_wire(windows).unwrap().iter().all(|field|field.number!=2));
|
||||
if formats.len()==2{
|
||||
let WireValue::Bytes(mac)=formats[1].value else{panic!("missing Mac format")};
|
||||
assert_eq!(number(mac,1),Ok(0));
|
||||
assert_eq!(bytes(mac,2),Ok(Some(MAC_TEXT.as_bytes())));
|
||||
}
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn unnamed_windows_offer_still_serves_utf16le_with_crlf_and_nul(){
|
||||
let mut provider=State::default();
|
||||
provider.offer(1,"A中🙂\nB\r\n".into()).unwrap();
|
||||
let mut ask=Vec::new();int(1,13,&mut ask);string(2,"test-key",&mut ask);
|
||||
let out=provider.request(&request(2,2,&ask),&mut||3).unwrap();
|
||||
assert_eq!(out.messages.iter().map(|m|m.0).collect::<Vec<_>>(),vec![22,21]);
|
||||
let confirm=bytes(bytes(&out.messages[0].1,5).unwrap().unwrap(),2).unwrap().unwrap();
|
||||
assert_eq!(number(confirm,1),Ok(1));assert_eq!(number(confirm,3),Ok(1));
|
||||
let block=bytes(bytes(&out.messages[1].1,9).unwrap().unwrap(),3).unwrap().unwrap();
|
||||
assert_eq!(text_field(block,1),Ok("test-key"));
|
||||
assert_eq!(number(block,2),Ok(0));
|
||||
assert_eq!(bytes(block,3).unwrap().unwrap(),&[0x41,0,0x2d,0x4e,0x3d,0xd8,0x42,0xde,13,0,10,0,0x42,0,13,0,10,0,0,0]);
|
||||
}
|
||||
#[test] fn mac_utf8_text_round_trips_both_directions(){
|
||||
// Mac host offer: format list {1 id 0, 2 "public.utf8-plain-text"} (observed live).
|
||||
let mut mac=Vec::new();int(1,0,&mut mac);string(2,MAC_TEXT,&mut mac);
|
||||
@@ -218,7 +247,7 @@ mod tests{
|
||||
assert_eq!(format_ids(&host_offer),vec![13]);
|
||||
let list=bytes(bytes(&host_offer,9).unwrap().unwrap(),1).unwrap().unwrap();
|
||||
let format=bytes(list,1).unwrap().unwrap();
|
||||
assert_eq!(text_field(format,2),Ok(WINDOWS_OFFER_NAME));
|
||||
assert_eq!(bytes(format,2),Ok(None));
|
||||
}
|
||||
#[test]
|
||||
fn desktop_clipboard_negotiates_and_buffers_unicode_until_confirmation(){
|
||||
|
||||
Reference in new issue
Block a user