Fix tiptap selection sync and toolbar event loop
This commit is contained in:
@@ -244,7 +244,10 @@ pub fn prepare_proxy_request(
|
||||
}
|
||||
|
||||
if let Some(origin) = supa_internal_origin.as_ref() {
|
||||
let port = origin.port().map(|value| value.to_string()).unwrap_or_default();
|
||||
let port = origin
|
||||
.port()
|
||||
.map(|value| value.to_string())
|
||||
.unwrap_or_default();
|
||||
if let Some(hostname) = origin.host_str() {
|
||||
add_allowed(hostname, &port);
|
||||
if is_local_hostname(hostname) {
|
||||
@@ -260,7 +263,10 @@ pub fn prepare_proxy_request(
|
||||
}
|
||||
|
||||
if let Some(origin) = convex_origin.as_ref() {
|
||||
let port = origin.port().map(|value| value.to_string()).unwrap_or_default();
|
||||
let port = origin
|
||||
.port()
|
||||
.map(|value| value.to_string())
|
||||
.unwrap_or_default();
|
||||
if let Some(hostname) = origin.host_str() {
|
||||
add_allowed(hostname, &port);
|
||||
if is_local_hostname(hostname) {
|
||||
@@ -275,7 +281,10 @@ pub fn prepare_proxy_request(
|
||||
.host_str()
|
||||
.ok_or_else(|| "目标 URL 缺少 hostname".to_string())?;
|
||||
|
||||
if is_private_ipv4(hostname) && !is_local_hostname(hostname) && !allowed_hostnames.contains(hostname) {
|
||||
if is_private_ipv4(hostname)
|
||||
&& !is_local_hostname(hostname)
|
||||
&& !allowed_hostnames.contains(hostname)
|
||||
{
|
||||
return Err("禁止访问内网/私有地址".into());
|
||||
}
|
||||
|
||||
@@ -303,8 +312,14 @@ pub fn prepare_proxy_request(
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(anon_key) = input.supabase_anon_key.filter(|value| !value.trim().is_empty()) {
|
||||
let matches_public = supa.as_ref().map(|(value, _)| value == hostname).unwrap_or(false);
|
||||
if let Some(anon_key) = input
|
||||
.supabase_anon_key
|
||||
.filter(|value| !value.trim().is_empty())
|
||||
{
|
||||
let matches_public = supa
|
||||
.as_ref()
|
||||
.map(|(value, _)| value == hostname)
|
||||
.unwrap_or(false);
|
||||
let matches_internal = supa_internal_origin
|
||||
.as_ref()
|
||||
.and_then(|value| value.host_str())
|
||||
@@ -332,7 +347,10 @@ pub fn prepare_callback(
|
||||
workspace_id: input.workspace_id.clone(),
|
||||
document_id: input.document_id.clone(),
|
||||
user_id: input.user_id.clone(),
|
||||
session_id: input.session_id.clone().or_else(|| Some("onlyoffice-callback".into())),
|
||||
session_id: input
|
||||
.session_id
|
||||
.clone()
|
||||
.or_else(|| Some("onlyoffice-callback".into())),
|
||||
});
|
||||
|
||||
if input.status != 2 && input.status != 6 {
|
||||
@@ -464,7 +482,8 @@ fn sign_hs256(payload: &Value, secret: &str) -> Result<String, String> {
|
||||
let header_part = URL_SAFE_NO_PAD.encode(header.to_string().as_bytes());
|
||||
let payload_part = URL_SAFE_NO_PAD.encode(payload.to_string().as_bytes());
|
||||
let signing_input = format!("{header_part}.{payload_part}");
|
||||
let mut mac = HmacSha256::new_from_slice(secret.as_bytes()).map_err(|error| error.to_string())?;
|
||||
let mut mac =
|
||||
HmacSha256::new_from_slice(secret.as_bytes()).map_err(|error| error.to_string())?;
|
||||
mac.update(signing_input.as_bytes());
|
||||
let signature = mac.finalize().into_bytes();
|
||||
let signature_part = URL_SAFE_NO_PAD.encode(signature);
|
||||
@@ -512,7 +531,9 @@ fn try_parse_origin_host(raw: Option<&str>) -> Option<(String, String)> {
|
||||
let url = Url::parse(value).ok()?;
|
||||
return Some((
|
||||
url.host_str()?.to_string(),
|
||||
url.port().map(|value| value.to_string()).unwrap_or_default(),
|
||||
url.port()
|
||||
.map(|value| value.to_string())
|
||||
.unwrap_or_default(),
|
||||
));
|
||||
}
|
||||
Some((value.to_string(), String::new()))
|
||||
@@ -574,7 +595,9 @@ mod tests {
|
||||
supabase_anon_key: Some("anon".into()),
|
||||
})
|
||||
.expect("proxy should prepare");
|
||||
assert!(result.target_url.starts_with("http://127.0.0.1:18000/storage/v1/"));
|
||||
assert!(result
|
||||
.target_url
|
||||
.starts_with("http://127.0.0.1:18000/storage/v1/"));
|
||||
assert_eq!(result.forward_headers.len(), 2);
|
||||
}
|
||||
|
||||
@@ -587,7 +610,9 @@ mod tests {
|
||||
user_id: Some("user_1".into()),
|
||||
session_id: None,
|
||||
status: 6,
|
||||
url: Some("http://app.example.com/onlyoffice-server/cache/files/out.docx?token=1".into()),
|
||||
url: Some(
|
||||
"http://app.example.com/onlyoffice-server/cache/files/out.docx?token=1".into(),
|
||||
),
|
||||
key: Some("doc_key_1".into()),
|
||||
onlyoffice_internal_url: "http://127.0.0.1:8082".into(),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user