TAMER: Fail on empty fragment ids (and fix underlying problem)
parent
a0893da577
commit
10b9caa7ad
|
@ -138,6 +138,11 @@
|
|||
<apply-templates mode="preproc:compile-fragments" />
|
||||
</template>
|
||||
|
||||
<!-- Do not compile these as consts -->
|
||||
<template mode="preproc:compile-fragments" priority="9"
|
||||
match="lv:meta/lv:prop/lv:const">
|
||||
<!-- ignore -->
|
||||
</template>
|
||||
|
||||
<template mode="preproc:compile-fragments" priority="5"
|
||||
match="lv:meta/lv:prop">
|
||||
|
|
|
@ -507,6 +507,7 @@ impl<'i, B: BufRead, I: Interner<'i>> XmloReader<'i, B, I> {
|
|||
|
||||
let id = filtered
|
||||
.find(|attr| attr.key == b"id")
|
||||
.filter(|attr| &*attr.value != b"")
|
||||
.map_or(Err(XmloError::UnassociatedFragment), |attr| {
|
||||
Ok(unsafe { interner.intern_utf8_unchecked(&attr.value) })
|
||||
})?;
|
||||
|
@ -1185,6 +1186,23 @@ mod test {
|
|||
}
|
||||
}
|
||||
|
||||
// Yes, this happened.
|
||||
fn fragment_fails_with_empty_id(sut, interner) {
|
||||
sut.reader.next_event = Some(Box::new(|_, _| {
|
||||
Ok(XmlEvent::Start(MockBytesStart::new(
|
||||
b"preproc:fragment",
|
||||
Some(MockAttributes::new(vec![MockAttribute::new(
|
||||
b"id", b"",
|
||||
)])),
|
||||
)))
|
||||
}));
|
||||
|
||||
match sut.read_event() {
|
||||
Err(XmloError::UnassociatedFragment) => (),
|
||||
bad => panic!("expected XmloError: {:?}", bad),
|
||||
}
|
||||
}
|
||||
|
||||
fn fragment_fails_with_missing_text(sut, interner) {
|
||||
sut.reader.next_text = Some(Err(XmlError::TextNotFound));
|
||||
|
||||
|
|
Loading…
Reference in New Issue