File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -274,6 +274,7 @@ where
274274 seed. deserialize ( de) . map ( Some )
275275 } else {
276276 self . skip_whitespaces ( ) ?;
277+
277278 // try getting from events (<key>value</key>)
278279 match self . de . peek ( ) ? {
279280 // If we have dedicated "$text" field, it will not be passed to "$value" field
Original file line number Diff line number Diff line change @@ -2789,8 +2789,16 @@ where
27892789 fn skip_whitespaces ( & mut self ) -> Result < ( ) , DeError > {
27902790 loop {
27912791 match self . peek ( ) ? {
2792+ // Skip only blank text nodes that contain a newline or carriage return
2793+ // (typical pretty-printed formatting). Preserve other blank text
2794+ // (e.g. single space) as they may be significant for some deserialization scenarios.
27922795 DeEvent :: Text ( e) if e. is_blank ( ) => {
2793- self . next ( ) ?;
2796+ let contains_newline = e. text . chars ( ) . any ( |c| c == '\n' || c == '\r' ) ;
2797+ if contains_newline {
2798+ self . next ( ) ?;
2799+ continue ;
2800+ }
2801+ break ;
27942802 }
27952803 _ => break ,
27962804 }
You can’t perform that action at this time.
0 commit comments