xmpp_parsers: --features disable-validation
It was broken in multiple ways: - xso did not honour it: unknown children and attributes would cause a parse error even with `--features disable-validation` set on parsers. For this, we introduce a new feature flag on xso, `non-pedantic`, which defaults unknown children and attributes to discard instead of fail. Note that individual XSOs can still choose to be always pedantic or always lenient by explicitly declaring the intent via the `on_unknown_child` and `on_unknown_attribute` metas. - Many tests in `xmpp_parsers` were broken with `--features disable-validation`. They now all pass while *still* being rn with `disable-validation` set: In that case, they test that parsing in fact succeeds.
This commit is contained in:
parent
2e66f848f6
commit
b8af0d8fa2
25 changed files with 104 additions and 24 deletions
|
|
@ -29,6 +29,7 @@ default = [ "std" ]
|
|||
macros = [ "dep:xso_proc", "rxml/macros" ]
|
||||
minidom = [ "xso_proc/minidom"]
|
||||
panicking-into-impl = ["xso_proc/panicking-into-impl"]
|
||||
non-pedantic = []
|
||||
std = []
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
|
|
|
|||
|
|
@ -324,13 +324,18 @@ impl<T: AsXmlText> AsOptionalXmlText for Option<T> {
|
|||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
|
||||
pub enum UnknownAttributePolicy {
|
||||
/// All unknown attributes are discarded.
|
||||
///
|
||||
/// This is the default policy if the crate is built with the
|
||||
/// `non-pedantic` feature.
|
||||
#[cfg_attr(feature = "non-pedantic", default)]
|
||||
Discard,
|
||||
|
||||
/// The first unknown attribute which is encountered generates a fatal
|
||||
/// parsing error.
|
||||
///
|
||||
/// This is the default policy.
|
||||
#[default]
|
||||
/// This is the default policy if the crate is built **without** the
|
||||
/// `non-pedantic` feature.
|
||||
#[cfg_attr(not(feature = "non-pedantic"), default)]
|
||||
Fail,
|
||||
}
|
||||
|
||||
|
|
@ -356,13 +361,18 @@ impl UnknownAttributePolicy {
|
|||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
|
||||
pub enum UnknownChildPolicy {
|
||||
/// All unknown children are discarded.
|
||||
///
|
||||
/// This is the default policy if the crate is built with the
|
||||
/// `non-pedantic` feature.
|
||||
#[cfg_attr(feature = "non-pedantic", default)]
|
||||
Discard,
|
||||
|
||||
/// The first unknown child which is encountered generates a fatal
|
||||
/// parsing error.
|
||||
///
|
||||
/// This is the default policy.
|
||||
#[default]
|
||||
/// This is the default policy if the crate is built **without** the
|
||||
/// `non-pedantic` feature.
|
||||
#[cfg_attr(not(feature = "non-pedantic"), default)]
|
||||
Fail,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue