diff --git a/Cargo.toml b/Cargo.toml
index 2d3122cb9084fd17e1434003c591f8e2036d1454..65935bab1f028d897229ee24541225749156fd59 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -28,3 +28,5 @@ try_from = "0.3.2"
[features]
# Build xmpp-parsers to make components instead of clients.
component = []
+# Compatibility mode
+compat = []
diff --git a/src/attention.rs b/src/attention.rs
index be33bb3b6f07d002163bfa2ee46d4f3a7bc6b6c3..c786f3137fce92ed8eb178329fda4ee4481a1da5 100644
--- a/src/attention.rs
+++ b/src/attention.rs
@@ -18,6 +18,7 @@ impl MessagePayload for Attention {}
#[cfg(test)]
mod tests {
use super::*;
+ #[cfg(not(feature = "compat"))]
use crate::error::Error;
use minidom::Element;
use try_from::TryFrom;
@@ -33,6 +34,7 @@ mod tests {
Attention::try_from(elem).unwrap();
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid_child() {
let elem: Element = ""
@@ -46,6 +48,7 @@ mod tests {
assert_eq!(message, "Unknown child in attention element.");
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid_attribute() {
let elem: Element = ""
diff --git a/src/bind.rs b/src/bind.rs
index fe9472b2cc3c2192c959cd7c076dc87d9adc2786..bd09d4f3b36aa326f51790cc3f0ad0f905f6a2a0 100644
--- a/src/bind.rs
+++ b/src/bind.rs
@@ -112,6 +112,7 @@ mod tests {
assert_eq!(bind, Bind::None);
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid_resource() {
let elem: Element = "resource"
diff --git a/src/blocking.rs b/src/blocking.rs
index d34fee3d97a1935c5d825e7bfc836408e74885a2..b2fe70df28c9bf49cbd6448a79504baf8f08f0d5 100644
--- a/src/blocking.rs
+++ b/src/blocking.rs
@@ -155,13 +155,16 @@ mod tests {
},
];
- let request_elem = elem.clone();
- let error = BlocklistRequest::try_from(request_elem).unwrap_err();
- let message = match error {
- Error::ParseError(string) => string,
- _ => panic!(),
- };
- assert_eq!(message, "Unknown child in blocklist element.");
+ #[cfg(not(feature = "compat"))]
+ {
+ let request_elem = elem.clone();
+ let error = BlocklistRequest::try_from(request_elem).unwrap_err();
+ let message = match error {
+ Error::ParseError(string) => string,
+ _ => panic!(),
+ };
+ assert_eq!(message, "Unknown child in blocklist element.");
+ }
let result_elem = elem.clone();
let result = BlocklistResult::try_from(result_elem).unwrap();
@@ -176,6 +179,7 @@ mod tests {
assert_eq!(unblock.items, two_items);
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid() {
let elem: Element = ""
diff --git a/src/caps.rs b/src/caps.rs
index 72b04263f14bfd58a51276de57be39026c63d21e..3befdc9bc2541de8d5d401c362f4733124eecb03 100644
--- a/src/caps.rs
+++ b/src/caps.rs
@@ -233,6 +233,7 @@ mod tests {
);
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid_child() {
let elem: Element = "K1Njy3HZBThlo4moOD5gBGhn0U0oK7/CbfLlIUDi6o4=".parse().unwrap();
diff --git a/src/chatstates.rs b/src/chatstates.rs
index 75d64d91b1549651793e2fd2c2775f811743f64a..9a972aa79a4e97a820c62ac1f76275936240b214 100644
--- a/src/chatstates.rs
+++ b/src/chatstates.rs
@@ -63,6 +63,7 @@ mod tests {
assert_eq!(message, "This is not a chatstate element.");
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid_child() {
let elem: Element = ""
@@ -76,6 +77,7 @@ mod tests {
assert_eq!(message, "Unknown child in chatstate element.");
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid_attribute() {
let elem: Element = ""
diff --git a/src/jingle_ft.rs b/src/jingle_ft.rs
index 381eb21fa288b1c37ac00ef139d4f033750b454c..359cd8b07c17f86094696d201573b5c9169bdc2f 100644
--- a/src/jingle_ft.rs
+++ b/src/jingle_ft.rs
@@ -510,13 +510,16 @@ mod tests {
};
assert_eq!(message, "Unknown child in received element.");
- let elem: Element = "".parse().unwrap();
- let error = Received::try_from(elem).unwrap_err();
- let message = match error {
- Error::ParseError(string) => string,
- _ => panic!(),
- };
- assert_eq!(message, "Unknown attribute in received element.");
+ #[cfg(not(feature = "compat"))]
+ {
+ let elem: Element = "".parse().unwrap();
+ let error = Received::try_from(elem).unwrap_err();
+ let message = match error {
+ Error::ParseError(string) => string,
+ _ => panic!(),
+ };
+ assert_eq!(message, "Unknown attribute in received element.");
+ }
let elem: Element =
""
@@ -575,13 +578,16 @@ mod tests {
};
assert_eq!(message, "This is not a file element.");
- let elem: Element = "w0mcJylzCn+AfvuGdqkty2+KP48=".parse().unwrap();
- let error = Checksum::try_from(elem).unwrap_err();
- let message = match error {
- Error::ParseError(string) => string,
- _ => panic!(),
- };
- assert_eq!(message, "Unknown attribute in checksum element.");
+ #[cfg(not(feature = "compat"))]
+ {
+ let elem: Element = "w0mcJylzCn+AfvuGdqkty2+KP48=".parse().unwrap();
+ let error = Checksum::try_from(elem).unwrap_err();
+ let message = match error {
+ Error::ParseError(string) => string,
+ _ => panic!(),
+ };
+ assert_eq!(message, "Unknown attribute in checksum element.");
+ }
let elem: Element = "w0mcJylzCn+AfvuGdqkty2+KP48=".parse().unwrap();
let error = Checksum::try_from(elem).unwrap_err();
@@ -631,11 +637,14 @@ mod tests {
let elem: Element = ""
.parse()
.unwrap();
- let error = Range::try_from(elem).unwrap_err();
- let message = match error {
- Error::ParseError(string) => string,
- _ => panic!(),
- };
- assert_eq!(message, "Unknown attribute in range element.");
+ #[cfg(not(feature = "compat"))]
+ {
+ let error = Range::try_from(elem).unwrap_err();
+ let message = match error {
+ Error::ParseError(string) => string,
+ _ => panic!(),
+ };
+ assert_eq!(message, "Unknown attribute in range element.");
+ }
}
}
diff --git a/src/macros.rs b/src/macros.rs
index 62c59736dc5a52435d988e88b30597f22a3f5097..daccec5c676346e14468723f34b9151e044972a2 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -248,6 +248,7 @@ macro_rules! check_ns_only {
macro_rules! check_no_children {
($elem:ident, $name:tt) => {
+ #[cfg(not(feature = "compat"))]
for _ in $elem.children() {
return Err(crate::error::Error::ParseError(concat!(
"Unknown child in ",
@@ -260,6 +261,7 @@ macro_rules! check_no_children {
macro_rules! check_no_attributes {
($elem:ident, $name:tt) => {
+ #[cfg(not(feature = "compat"))]
for _ in $elem.attrs() {
return Err(crate::error::Error::ParseError(concat!(
"Unknown attribute in ",
@@ -272,6 +274,7 @@ macro_rules! check_no_attributes {
macro_rules! check_no_unknown_attributes {
($elem:ident, $name:tt, [$($attr:tt),*]) => (
+ #[cfg(not(feature = "compat"))]
for (_attr, _) in $elem.attrs() {
$(
if _attr == $attr {
diff --git a/src/message_correct.rs b/src/message_correct.rs
index 9e7a08f726c1e789b2794949a3888ec4d8524eb8..e0d22d6257322d3a31bccbb32d20ed6cfb44ce0c 100644
--- a/src/message_correct.rs
+++ b/src/message_correct.rs
@@ -45,6 +45,7 @@ mod tests {
Replace::try_from(elem).unwrap();
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid_attribute() {
let elem: Element = ""
diff --git a/src/muc/muc.rs b/src/muc/muc.rs
index 32df468d7e46f8548656f6a9503daef514dc610f..40528383da094ad9438d492d6ec92f95cf291540 100644
--- a/src/muc/muc.rs
+++ b/src/muc/muc.rs
@@ -142,6 +142,7 @@ mod tests {
assert_eq!(elem, elem2);
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_muc_invalid_attribute() {
let elem: Element = ""
diff --git a/src/muc/user.rs b/src/muc/user.rs
index 2c1a6926a98b9099f207268bcb683ec9127070a1..a104e319f9104715a22655c4901631cdad49d1a9 100644
--- a/src/muc/user.rs
+++ b/src/muc/user.rs
@@ -303,6 +303,7 @@ mod tests {
assert!(elem.compare_to(&elem2));
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid_attribute() {
let elem: Element = "
@@ -343,6 +344,7 @@ mod tests {
assert_eq!(message, "Required attribute 'code' missing.");
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_status_invalid_child() {
let elem: Element = "
@@ -513,6 +515,7 @@ mod tests {
assert_eq!(reason.0, "Reason".to_owned());
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_reason_invalid_attribute() {
let elem: Element = "
@@ -528,6 +531,7 @@ mod tests {
assert_eq!(message, "Unknown attribute in reason element.".to_owned());
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_reason_invalid() {
let elem: Element = "
@@ -545,6 +549,7 @@ mod tests {
assert_eq!(message, "Unknown child in reason element.".to_owned());
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_item_invalid_attr() {
let elem: Element = "
diff --git a/src/nick.rs b/src/nick.rs
index edf8dcacce17b23e54ac39fcbea32b87aad8d5a2..67a45ff9c5342ea6c2216ec4a4f99865e0aae859 100644
--- a/src/nick.rs
+++ b/src/nick.rs
@@ -14,6 +14,7 @@ generate_elem_id!(
#[cfg(test)]
mod tests {
use super::*;
+ #[cfg(not(feature = "compat"))]
use crate::error::Error;
use minidom::Element;
use try_from::TryFrom;
@@ -48,6 +49,7 @@ mod tests {
assert_eq!(elem1, elem2);
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid() {
let elem: Element = ""
@@ -61,6 +63,7 @@ mod tests {
assert_eq!(message, "Unknown child in nick element.");
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid_attribute() {
let elem: Element = ""
diff --git a/src/ping.rs b/src/ping.rs
index 4cb25f649c453db84f9879f5871c743df187898f..6f48dd5592941854555995db680452f7a901ccaf 100644
--- a/src/ping.rs
+++ b/src/ping.rs
@@ -20,6 +20,7 @@ impl IqGetPayload for Ping {}
#[cfg(test)]
mod tests {
use super::*;
+ #[cfg(not(feature = "compat"))]
use crate::error::Error;
use minidom::Element;
use try_from::TryFrom;
@@ -42,6 +43,7 @@ mod tests {
assert_eq!(elem1, elem2);
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid() {
let elem: Element = ""
@@ -55,6 +57,7 @@ mod tests {
assert_eq!(message, "Unknown child in ping element.");
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid_attribute() {
let elem: Element = "".parse().unwrap();
diff --git a/src/presence.rs b/src/presence.rs
index 1f9846c2b7dc493b5f37d6c135327ebfcd125a68..20d63e879e48ac4af6f1a147b30010a785d215cd 100644
--- a/src/presence.rs
+++ b/src/presence.rs
@@ -570,6 +570,7 @@ mod tests {
assert!(payload.is("test", "invalid"));
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid_status_child() {
#[cfg(not(feature = "component"))]
@@ -589,6 +590,7 @@ mod tests {
assert_eq!(message, "Unknown child in status element.");
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid_attribute() {
#[cfg(not(feature = "component"))]
diff --git a/src/pubsub/event.rs b/src/pubsub/event.rs
index fac8e2fe26b822297abf1438cfe6ae4332bd065d..0cad1cc0379fb9b7ad357821ad8f5a899057734b 100644
--- a/src/pubsub/event.rs
+++ b/src/pubsub/event.rs
@@ -420,6 +420,7 @@ mod tests {
assert_eq!(message, "Unknown child in event element.");
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid_attribute() {
let elem: Element = ""
diff --git a/src/roster.rs b/src/roster.rs
index 40cc7a25dc7f8a7f935306df4507e3cff8d4862e..c0d869d1d0079196f04dfa651fbdce888178d721 100644
--- a/src/roster.rs
+++ b/src/roster.rs
@@ -245,6 +245,7 @@ mod tests {
assert_eq!(roster.items[0].subscription, Subscription::Remove);
}
+ #[cfg(not(feature = "compat"))]
#[test]
fn test_invalid() {
let elem: Element = ""
diff --git a/src/sasl.rs b/src/sasl.rs
index 86e10760b996632ded068544d3e2c05ded68c544..21e585722aaf113c0c1a391ae2c79d28aed00ed8 100644
--- a/src/sasl.rs
+++ b/src/sasl.rs
@@ -289,6 +289,7 @@ mod tests {
);
}
+ #[cfg(feature = "compat")]
#[test]
fn failure_with_non_prefixed_text_lang() {
let elem: Element = "
@@ -299,9 +300,5 @@ mod tests {
.unwrap();
let failure = Failure::try_from(elem).unwrap();
assert_eq!(failure.defined_condition, DefinedCondition::NotAuthorized);
- assert_eq!(
- failure.texts["en"],
- String::from("Invalid username or password")
- );
}
}