Rename "compat" into "disable-validation", to insist on it breaking some guarantees.

Emmanuel Gil Peyrot created

Change summary

.gitlab-ci.yml         |  8 ++++----
Cargo.toml             |  4 ++--
src/attention.rs       |  6 +++---
src/bind.rs            |  2 +-
src/blocking.rs        |  4 ++--
src/caps.rs            |  2 +-
src/chatstates.rs      |  4 ++--
src/jingle_ft.rs       |  6 +++---
src/macros.rs          |  6 +++---
src/message_correct.rs |  2 +-
src/muc/muc.rs         |  2 +-
src/muc/user.rs        | 10 +++++-----
src/nick.rs            |  6 +++---
src/ping.rs            |  6 +++---
src/presence.rs        |  4 ++--
src/pubsub/event.rs    |  2 +-
src/roster.rs          |  2 +-
src/sasl.rs            |  2 +-
18 files changed, 39 insertions(+), 39 deletions(-)

Detailed changes

.gitlab-ci.yml 🔗

@@ -18,12 +18,12 @@ rust-nightly:
     - cargo build --verbose --no-default-features --features=$FEATURES
     - cargo test --verbose --no-default-features --features=$FEATURES
 
-"rust-latest with features=compat":
+"rust-latest with features=disable-validation":
   extends: rust-latest
   variables:
-    FEATURES: "compat"
+    FEATURES: "disable-validation"
 
-"rust-nightly with features=compat":
+"rust-nightly with features=disable-validation":
   extends: rust-nightly
   variables:
-    FEATURES: "compat"
+    FEATURES: "disable-validation"

Cargo.toml 🔗

@@ -28,5 +28,5 @@ try_from = "0.3.2"
 [features]
 # Build xmpp-parsers to make components instead of clients.
 component = []
-# Compatibility mode
-compat = []
+# Disable validation of unknown attributes.
+disable-validation = []

src/attention.rs 🔗

@@ -18,7 +18,7 @@ impl MessagePayload for Attention {}
 #[cfg(test)]
 mod tests {
     use super::*;
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     use crate::error::Error;
     use minidom::Element;
     use try_from::TryFrom;
@@ -34,7 +34,7 @@ mod tests {
         Attention::try_from(elem).unwrap();
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_child() {
         let elem: Element = "<attention xmlns='urn:xmpp:attention:0'><coucou/></attention>"
@@ -48,7 +48,7 @@ mod tests {
         assert_eq!(message, "Unknown child in attention element.");
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_attribute() {
         let elem: Element = "<attention xmlns='urn:xmpp:attention:0' coucou=''/>"

src/bind.rs 🔗

@@ -112,7 +112,7 @@ mod tests {
         assert_eq!(bind, Bind::None);
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_resource() {
         let elem: Element = "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource attr='coucou'>resource</resource></bind>"

src/blocking.rs 🔗

@@ -168,7 +168,7 @@ mod tests {
         assert_eq!(unblock.items, two_items);
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid() {
         let elem: Element = "<blocklist xmlns='urn:xmpp:blocking' coucou=''/>"
@@ -211,7 +211,7 @@ mod tests {
         assert_eq!(message, "Unknown attribute in unblock element.");
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_non_empty_blocklist_request() {
         let elem: Element = "<blocklist xmlns='urn:xmpp:blocking'><item jid='coucou@coucou'/><item jid='domain'/></blocklist>".parse().unwrap();

src/caps.rs 🔗

@@ -233,7 +233,7 @@ mod tests {
         );
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_child() {
         let elem: Element = "<c xmlns='http://jabber.org/protocol/caps'><hash xmlns='urn:xmpp:hashes:2' algo='sha-256'>K1Njy3HZBThlo4moOD5gBGhn0U0oK7/CbfLlIUDi6o4=</hash></c>".parse().unwrap();

src/chatstates.rs 🔗

@@ -63,7 +63,7 @@ mod tests {
         assert_eq!(message, "This is not a chatstate element.");
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_child() {
         let elem: Element = "<gone xmlns='http://jabber.org/protocol/chatstates'><coucou/></gone>"
@@ -77,7 +77,7 @@ mod tests {
         assert_eq!(message, "Unknown child in chatstate element.");
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_attribute() {
         let elem: Element = "<inactive xmlns='http://jabber.org/protocol/chatstates' coucou=''/>"

src/jingle_ft.rs 🔗

@@ -530,7 +530,7 @@ mod tests {
         assert_eq!(message, "Unknown value for 'creator' attribute.");
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_received() {
         let elem: Element = "<received xmlns='urn:xmpp:jingle:apps:file-transfer:5' name='coucou' creator='initiator' coucou=''/>".parse().unwrap();
@@ -596,7 +596,7 @@ mod tests {
         assert_eq!(message, "Unknown value for 'creator' attribute.");
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_checksum() {
         let elem: Element = "<checksum xmlns='urn:xmpp:jingle:apps:file-transfer:5' name='coucou' creator='initiator' coucou=''><file><hash xmlns='urn:xmpp:hashes:2' algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash></file></checksum>".parse().unwrap();
@@ -637,7 +637,7 @@ mod tests {
         assert_eq!(range2.hashes, hashes);
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_range() {
         let elem: Element = "<range xmlns='urn:xmpp:jingle:apps:file-transfer:5' coucou=''/>"

src/macros.rs 🔗

@@ -248,7 +248,7 @@ macro_rules! check_ns_only {
 
 macro_rules! check_no_children {
     ($elem:ident, $name:tt) => {
-        #[cfg(not(feature = "compat"))]
+        #[cfg(not(feature = "disable-validation"))]
         for _ in $elem.children() {
             return Err(crate::error::Error::ParseError(concat!(
                 "Unknown child in ",
@@ -261,7 +261,7 @@ macro_rules! check_no_children {
 
 macro_rules! check_no_attributes {
     ($elem:ident, $name:tt) => {
-        #[cfg(not(feature = "compat"))]
+        #[cfg(not(feature = "disable-validation"))]
         for _ in $elem.attrs() {
             return Err(crate::error::Error::ParseError(concat!(
                 "Unknown attribute in ",
@@ -274,7 +274,7 @@ macro_rules! check_no_attributes {
 
 macro_rules! check_no_unknown_attributes {
     ($elem:ident, $name:tt, [$($attr:tt),*]) => (
-        #[cfg(not(feature = "compat"))]
+        #[cfg(not(feature = "disable-validation"))]
         for (_attr, _) in $elem.attrs() {
             $(
                 if _attr == $attr {

src/message_correct.rs 🔗

@@ -45,7 +45,7 @@ mod tests {
         Replace::try_from(elem).unwrap();
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_attribute() {
         let elem: Element = "<replace xmlns='urn:xmpp:message-correct:0' coucou=''/>"

src/muc/muc.rs 🔗

@@ -142,7 +142,7 @@ mod tests {
         assert_eq!(elem, elem2);
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_muc_invalid_attribute() {
         let elem: Element = "<x xmlns='http://jabber.org/protocol/muc' coucou=''/>"

src/muc/user.rs 🔗

@@ -303,7 +303,7 @@ mod tests {
         assert!(elem.compare_to(&elem2));
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_attribute() {
         let elem: Element = "
@@ -344,7 +344,7 @@ mod tests {
         assert_eq!(message, "Required attribute 'code' missing.");
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_status_invalid_child() {
         let elem: Element = "
@@ -515,7 +515,7 @@ mod tests {
         assert_eq!(reason.0, "Reason".to_owned());
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_reason_invalid_attribute() {
         let elem: Element = "
@@ -531,7 +531,7 @@ mod tests {
         assert_eq!(message, "Unknown attribute in reason element.".to_owned());
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_reason_invalid() {
         let elem: Element = "
@@ -549,7 +549,7 @@ mod tests {
         assert_eq!(message, "Unknown child in reason element.".to_owned());
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_item_invalid_attr() {
         let elem: Element = "

src/nick.rs 🔗

@@ -14,7 +14,7 @@ generate_elem_id!(
 #[cfg(test)]
 mod tests {
     use super::*;
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     use crate::error::Error;
     use minidom::Element;
     use try_from::TryFrom;
@@ -49,7 +49,7 @@ mod tests {
         assert_eq!(elem1, elem2);
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid() {
         let elem: Element = "<nick xmlns='http://jabber.org/protocol/nick'><coucou/></nick>"
@@ -63,7 +63,7 @@ mod tests {
         assert_eq!(message, "Unknown child in nick element.");
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_attribute() {
         let elem: Element = "<nick xmlns='http://jabber.org/protocol/nick' coucou=''/>"

src/ping.rs 🔗

@@ -20,7 +20,7 @@ impl IqGetPayload for Ping {}
 #[cfg(test)]
 mod tests {
     use super::*;
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     use crate::error::Error;
     use minidom::Element;
     use try_from::TryFrom;
@@ -43,7 +43,7 @@ mod tests {
         assert_eq!(elem1, elem2);
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid() {
         let elem: Element = "<ping xmlns='urn:xmpp:ping'><coucou/></ping>"
@@ -57,7 +57,7 @@ mod tests {
         assert_eq!(message, "Unknown child in ping element.");
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_attribute() {
         let elem: Element = "<ping xmlns='urn:xmpp:ping' coucou=''/>".parse().unwrap();

src/presence.rs 🔗

@@ -570,7 +570,7 @@ mod tests {
         assert!(payload.is("test", "invalid"));
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_status_child() {
         #[cfg(not(feature = "component"))]
@@ -590,7 +590,7 @@ mod tests {
         assert_eq!(message, "Unknown child in status element.");
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_attribute() {
         #[cfg(not(feature = "component"))]

src/pubsub/event.rs 🔗

@@ -420,7 +420,7 @@ mod tests {
         assert_eq!(message, "Unknown child in event element.");
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid_attribute() {
         let elem: Element = "<event xmlns='http://jabber.org/protocol/pubsub#event' coucou=''/>"

src/roster.rs 🔗

@@ -245,7 +245,7 @@ mod tests {
         assert_eq!(roster.items[0].subscription, Subscription::Remove);
     }
 
-    #[cfg(not(feature = "compat"))]
+    #[cfg(not(feature = "disable-validation"))]
     #[test]
     fn test_invalid() {
         let elem: Element = "<query xmlns='jabber:iq:roster'><coucou/></query>"

src/sasl.rs 🔗

@@ -289,7 +289,7 @@ mod tests {
         );
     }
 
-    #[cfg(feature = "compat")]
+    #[cfg(feature = "disable-validation")]
     #[test]
     fn failure_with_non_prefixed_text_lang() {
         let elem: Element = "<failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>