forked from lavina/lavina
1
0
Fork 0

improve validation

This commit is contained in:
Nikita Vilunov 2023-09-21 17:00:53 +02:00
parent 372efc3701
commit a16cd01a2c
1 changed files with 10 additions and 7 deletions

View File

@ -106,16 +106,19 @@ impl FromXml for BindRequest {
match event { match event {
Event::Start(bytes) if bytes.name().0 == b"resource" => { Event::Start(bytes) if bytes.name().0 == b"resource" => {
let (namespace, event) = yield; let (namespace, event) = yield;
if let Event::Text(text) = event { let Event::Text(text) = event else {
resource = Some(text.as_bytes().into());
}
let (namespace, event) = yield;
if let Event::End(_) = event {
} else {
return Err(ffail!("Unexpected XML event: {event:?}")); return Err(ffail!("Unexpected XML event: {event:?}"));
};
resource = Some(text.as_bytes().into());
let (namespace, event) = yield;
let Event::End(bytes) = event else {
return Err(ffail!("Unexpected XML event: {event:?}"));
};
if bytes.name().0 != b"resource" {
return Err(ffail!("Unexpected XML tag: {:?}", bytes.name()));
} }
} }
Event::End(bytes_) => { Event::End(bytes) if bytes.name().0 == BindRequest::NAME.as_bytes() => {
break; break;
} }
_ => return Err(ffail!("Unexpected XML event: {event:?}")), _ => return Err(ffail!("Unexpected XML event: {event:?}")),