| 1 | use craterust-analyzer cargo xml-rs 0.8.19 crate/::readerrust-analyzer cargo xml-rs 0.8.19 reader/::errorrust-analyzer cargo xml-rs 0.8.19 reader/error/::SyntaxErrorrust-analyzer cargo xml-rs 0.8.19 reader/error/SyntaxError#; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::charrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/; |
| 3 | use craterust-analyzer cargo xml-rs 0.8.19 crate/::commonrust-analyzer cargo xml-rs 0.8.19 common/::{is_name_charrust-analyzer cargo xml-rs 0.8.19 common/is_name_char()., is_name_start_charrust-analyzer cargo xml-rs 0.8.19 common/is_name_start_char()., is_whitespace_charrust-analyzer cargo xml-rs 0.8.19 common/is_whitespace_char().}; |
| 4 | use craterust-analyzer cargo xml-rs 0.8.19 crate/::readerrust-analyzer cargo xml-rs 0.8.19 reader/::lexerrust-analyzer cargo xml-rs 0.8.19 reader/lexer/::Tokenrust-analyzer cargo xml-rs 0.8.19 reader/lexer/Token#; |
| 5 | use superrust-analyzer cargo xml-rs 0.8.19 reader/parser/::{PullParserrust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#, Resultrust-analyzer cargo xml-rs 0.8.19 reader/parser/Result#, Staterust-analyzer cargo xml-rs 0.8.19 reader/parser/State#}; |
| 6 | |
| 7 | impl PullParserrust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser# { |
| 8 | pub fn inside_referencerust-analyzer cargo xml-rs 0.8.19 reader/parser/inside_reference/impl#[PullParser]inside_reference().(&mut self, t: Tokenrust-analyzer cargo xml-rs 0.8.19 reader/lexer/Token#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Resultrust-analyzer cargo xml-rs 0.8.19 reader/parser/Result#> { |
| 9 | match t { |
| 10 | Tokenrust-analyzer cargo xml-rs 0.8.19 reader/lexer/Token#::Characterrust-analyzer cargo xml-rs 0.8.19 reader/lexer/Token#Character#(c) if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.datarust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#data..ref_datarust-analyzer cargo xml-rs 0.8.19 reader/parser/MarkupData#ref_data..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() && is_name_charrust-analyzer cargo xml-rs 0.8.19 common/is_name_char().(c) || |
| 11 | self.datarust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#data..ref_datarust-analyzer cargo xml-rs 0.8.19 reader/parser/MarkupData#ref_data..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() && (is_name_start_charrust-analyzer cargo xml-rs 0.8.19 common/is_name_start_char().(c) || c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'#') => { |
| 12 | self.datarust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#data..ref_datarust-analyzer cargo xml-rs 0.8.19 reader/parser/MarkupData#ref_data..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(c); |
| 13 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 14 | } |
| 15 | |
| 16 | Tokenrust-analyzer cargo xml-rs 0.8.19 reader/lexer/Token#::ReferenceEndrust-analyzer cargo xml-rs 0.8.19 reader/lexer/Token#ReferenceEnd# => { |
| 17 | let name = self.datarust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#data..take_ref_datarust-analyzer cargo xml-rs 0.8.19 reader/parser/impl#[MarkupData]take_ref_data().(); |
| 18 | if name.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() { |
| 19 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.errorrust-analyzer cargo xml-rs 0.8.19 reader/parser/impl#[PullParser]error().(SyntaxErrorrust-analyzer cargo xml-rs 0.8.19 reader/error/SyntaxError#::EmptyEntityrust-analyzer cargo xml-rs 0.8.19 reader/error/SyntaxError#EmptyEntity#)); |
| 20 | } |
| 21 | |
| 22 | let c = match &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().name { |
| 23 | "lt" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('<'), |
| 24 | "gt" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('>'), |
| 25 | "amp" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('&'), |
| 26 | "apos" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('\''), |
| 27 | "quot" => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#('"'), |
| 28 | _ if name.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('#') => match self.numeric_reference_from_strrust-analyzer cargo xml-rs 0.8.19 reader/parser/inside_reference/impl#[PullParser]numeric_reference_from_str().(&name[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().) { |
| 29 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(c) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c), |
| 30 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.errorrust-analyzer cargo xml-rs 0.8.19 reader/parser/impl#[PullParser]error().(e)) |
| 31 | }, |
| 32 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 33 | }; |
| 34 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) = c { |
| 35 | self.bufrust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#buf..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(c); |
| 36 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v) = self.configrust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#config..crust-analyzer cargo xml-rs 0.8.19 reader/config/ParserConfig2#c..extra_entitiesrust-analyzer cargo xml-rs 0.8.19 reader/config/ParserConfig#extra_entities..getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&name) { |
| 37 | self.bufrust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#buf..push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(v); |
| 38 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v) = self.entitiesrust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#entities..getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&name) { |
| 39 | if self.state_after_referencerust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#state_after_reference. rust-analyzer cargo xml-rs 0.8.19 reader/parser/impl#[State][`PartialEq<Self>`]eq().==rust-analyzer cargo xml-rs 0.8.19 reader/parser/impl#[State][`PartialEq<Self>`]eq(). rust-analyzer cargo xml-rs 0.8.19 reader/parser/impl#[State][`PartialEq<Self>`]eq().Staterust-analyzer cargo xml-rs 0.8.19 reader/parser/State#::OutsideTagrust-analyzer cargo xml-rs 0.8.19 reader/parser/State#OutsideTag# { |
| 40 | // an entity can expand to *elements*, so outside of a tag it needs a full reparse |
| 41 | if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) = self.lexerrust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#lexer..reparserust-analyzer cargo xml-rs 0.8.19 reader/lexer/impl#[Lexer]reparse().(v) { |
| 42 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e)); |
| 43 | } |
| 44 | } else { |
| 45 | // however, inside attributes it's not allowed to affect attribute quoting, |
| 46 | // so it can't be fed to the lexer |
| 47 | self.bufrust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#buf..push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(v); |
| 48 | } |
| 49 | } else { |
| 50 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.errorrust-analyzer cargo xml-rs 0.8.19 reader/parser/impl#[PullParser]error().(SyntaxErrorrust-analyzer cargo xml-rs 0.8.19 reader/error/SyntaxError#::UnexpectedEntityrust-analyzer cargo xml-rs 0.8.19 reader/error/SyntaxError#UnexpectedEntity#(name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))); |
| 51 | } |
| 52 | let prev_st = self.state_after_referencerust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#state_after_reference.; |
| 53 | if prev_st rust-analyzer cargo xml-rs 0.8.19 reader/parser/impl#[State][`PartialEq<Self>`]eq().==rust-analyzer cargo xml-rs 0.8.19 reader/parser/impl#[State][`PartialEq<Self>`]eq(). rust-analyzer cargo xml-rs 0.8.19 reader/parser/impl#[State][`PartialEq<Self>`]eq().Staterust-analyzer cargo xml-rs 0.8.19 reader/parser/State#::OutsideTagrust-analyzer cargo xml-rs 0.8.19 reader/parser/State#OutsideTag# && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_whitespace_charrust-analyzer cargo xml-rs 0.8.19 common/is_whitespace_char().(self.bufrust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#buf..charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Chars<'a>`][Iterator]last().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().('\0')) { |
| 54 | self.inside_whitespacerust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#inside_whitespace. = false; |
| 55 | } |
| 56 | self.into_state_continuerust-analyzer cargo xml-rs 0.8.19 reader/parser/impl#[PullParser]into_state_continue().(prev_st) |
| 57 | } |
| 58 | |
| 59 | _ => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.errorrust-analyzer cargo xml-rs 0.8.19 reader/parser/impl#[PullParser]error().(SyntaxErrorrust-analyzer cargo xml-rs 0.8.19 reader/error/SyntaxError#::UnexpectedTokenInEntityrust-analyzer cargo xml-rs 0.8.19 reader/error/SyntaxError#UnexpectedTokenInEntity#(t))), |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | pub(craterust-analyzer cargo xml-rs 0.8.19 crate/) fn numeric_reference_from_strrust-analyzer cargo xml-rs 0.8.19 reader/parser/inside_reference/impl#[PullParser]numeric_reference_from_str().(&self, num_str: &str) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<char, SyntaxErrorrust-analyzer cargo xml-rs 0.8.19 reader/error/SyntaxError#> { |
| 64 | let val = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(hex) = num_str.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().('x') { |
| 65 | u32::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_str_radix().(hex, 16).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(move |_| SyntaxErrorrust-analyzer cargo xml-rs 0.8.19 reader/error/SyntaxError#::InvalidNumericEntityrust-analyzer cargo xml-rs 0.8.19 reader/error/SyntaxError#InvalidNumericEntity#(num_str.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 66 | } else { |
| 67 | u32::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_str_radix().(num_str, 10).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(move |_| SyntaxErrorrust-analyzer cargo xml-rs 0.8.19 reader/error/SyntaxError#::InvalidNumericEntityrust-analyzer cargo xml-rs 0.8.19 reader/error/SyntaxError#InvalidNumericEntity#(num_str.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 68 | }; |
| 69 | match charrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/::from_u32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/from_u32().(val) { |
| 70 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) if self.is_valid_xml_charrust-analyzer cargo xml-rs 0.8.19 reader/parser/impl#[PullParser]is_valid_xml_char().(c) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(c), |
| 71 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_) if self.configrust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#config..crust-analyzer cargo xml-rs 0.8.19 reader/config/ParserConfig2#c..replace_unknown_entity_referencesrust-analyzer cargo xml-rs 0.8.19 reader/config/ParserConfig#replace_unknown_entity_references. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#('\u{fffd}'), |
| 72 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# if self.configrust-analyzer cargo xml-rs 0.8.19 reader/parser/PullParser#config..crust-analyzer cargo xml-rs 0.8.19 reader/config/ParserConfig2#c..replace_unknown_entity_referencesrust-analyzer cargo xml-rs 0.8.19 reader/config/ParserConfig#replace_unknown_entity_references. => { |
| 73 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#('\u{fffd}') |
| 74 | }, |
| 75 | _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(SyntaxErrorrust-analyzer cargo xml-rs 0.8.19 reader/error/SyntaxError#::InvalidCharacterEntityrust-analyzer cargo xml-rs 0.8.19 reader/error/SyntaxError#InvalidCharacterEntity#(val)), |
| 76 | } |
| 77 | } |
| 78 | } |