mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-28 07:57:01 +00:00
fix(server): adapt quick-xml name handling (#6458)
This commit is contained in:
@@ -8176,7 +8176,7 @@ fn is_zero_rule_lifecycle_tombstone(raw: &[u8]) -> bool {
|
|||||||
match reader.read_event() {
|
match reader.read_event() {
|
||||||
Ok(quick_xml::events::Event::Start(element)) => {
|
Ok(quick_xml::events::Event::Start(element)) => {
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
if seen_root || closed_root || element.name().as_ref() != b"LifecycleConfiguration" {
|
if seen_root || closed_root || element.name().as_ref() != "LifecycleConfiguration" {
|
||||||
break false;
|
break false;
|
||||||
}
|
}
|
||||||
seen_root = true;
|
seen_root = true;
|
||||||
@@ -8185,7 +8185,7 @@ fn is_zero_rule_lifecycle_tombstone(raw: &[u8]) -> bool {
|
|||||||
}
|
}
|
||||||
Ok(quick_xml::events::Event::Empty(element)) => {
|
Ok(quick_xml::events::Event::Empty(element)) => {
|
||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
if seen_root || closed_root || element.name().as_ref() != b"LifecycleConfiguration" {
|
if seen_root || closed_root || element.name().as_ref() != "LifecycleConfiguration" {
|
||||||
break false;
|
break false;
|
||||||
}
|
}
|
||||||
seen_root = true;
|
seen_root = true;
|
||||||
@@ -8208,7 +8208,9 @@ fn is_zero_rule_lifecycle_tombstone(raw: &[u8]) -> bool {
|
|||||||
seen_declaration = true;
|
seen_declaration = true;
|
||||||
}
|
}
|
||||||
Ok(quick_xml::events::Event::DocType(_)) => break false,
|
Ok(quick_xml::events::Event::DocType(_)) => break false,
|
||||||
Ok(quick_xml::events::Event::Text(text)) if depth == 0 && !text.iter().all(u8::is_ascii_whitespace) => {
|
Ok(quick_xml::events::Event::Text(text))
|
||||||
|
if depth == 0 && !text.as_ref().bytes().all(|byte| byte.is_ascii_whitespace()) =>
|
||||||
|
{
|
||||||
break false;
|
break false;
|
||||||
}
|
}
|
||||||
Ok(quick_xml::events::Event::Text(_)) => {}
|
Ok(quick_xml::events::Event::Text(_)) => {}
|
||||||
|
|||||||
@@ -1653,13 +1653,8 @@ fn add_sts_response_metadata(xml: &str, request_id: &str) -> Option<Bytes> {
|
|||||||
if !is_sts_success_response_tag(element.local_name().as_ref()) {
|
if !is_sts_success_response_tag(element.local_name().as_ref()) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
root_prefix = element
|
root_prefix = element.name().prefix().map(|prefix| prefix.as_ref().to_owned());
|
||||||
.name()
|
} else if depth == 1 && element.local_name().as_ref() == STS_RESPONSE_METADATA_TAG {
|
||||||
.prefix()
|
|
||||||
.map(|prefix| std::str::from_utf8(prefix.as_ref()).map(str::to_owned))
|
|
||||||
.transpose()
|
|
||||||
.ok()?;
|
|
||||||
} else if depth == 1 && element.local_name().as_ref() == STS_RESPONSE_METADATA_TAG.as_bytes() {
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
depth += 1;
|
depth += 1;
|
||||||
@@ -1668,7 +1663,7 @@ fn add_sts_response_metadata(xml: &str, request_id: &str) -> Option<Bytes> {
|
|||||||
if depth == 0 {
|
if depth == 0 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
if depth == 1 && element.local_name().as_ref() == STS_RESPONSE_METADATA_TAG.as_bytes() {
|
if depth == 1 && element.local_name().as_ref() == STS_RESPONSE_METADATA_TAG {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1702,8 +1697,8 @@ fn add_sts_response_metadata(xml: &str, request_id: &str) -> Option<Bytes> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_sts_success_response_tag(tag: &[u8]) -> bool {
|
fn is_sts_success_response_tag(tag: &str) -> bool {
|
||||||
STS_SUCCESS_RESPONSE_TAGS.iter().any(|candidate| candidate.as_bytes() == tag)
|
STS_SUCCESS_RESPONSE_TAGS.contains(&tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_sts_error_response(xml: &str, status: StatusCode, request_id: &str) -> String {
|
fn wrap_sts_error_response(xml: &str, status: StatusCode, request_id: &str) -> String {
|
||||||
|
|||||||
Reference in New Issue
Block a user