mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
Parse KML without converting to UTF-8 and back to bytes
This commit is contained in:
committed by
Floris Bruynooghe
parent
04bb6997a2
commit
672fe2dfd7
@@ -64,11 +64,10 @@ impl Kml {
|
|||||||
Default::default()
|
Default::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse(context: &Context, content: &[u8]) -> Result<Self, Error> {
|
pub fn parse(context: &Context, to_parse: &[u8]) -> Result<Self, Error> {
|
||||||
ensure!(content.len() <= 1024 * 1024, "kml-file is too large");
|
ensure!(to_parse.len() <= 1024 * 1024, "kml-file is too large");
|
||||||
|
|
||||||
let to_parse = String::from_utf8_lossy(content);
|
let mut reader = quick_xml::Reader::from_reader(to_parse);
|
||||||
let mut reader = quick_xml::Reader::from_str(&to_parse);
|
|
||||||
reader.trim_text(true);
|
reader.trim_text(true);
|
||||||
|
|
||||||
let mut kml = Kml::new();
|
let mut kml = Kml::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user