Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoding Google Maps point KMZ file ends up with a panic #1

Closed
obbardc opened this issue Mar 6, 2021 · 3 comments · Fixed by #2
Closed

Decoding Google Maps point KMZ file ends up with a panic #1

obbardc opened this issue Mar 6, 2021 · 3 comments · Fixed by #2

Comments

@obbardc
Copy link

obbardc commented Mar 6, 2021

Hi!
I am getting an error when attempting to import a KMZ file from a user-submitted Google map.
Currently I am just trying to load the file and print the decoded data - but the eventual goal is to print out the lat/long/names of each added point.

KMZ file downloaded from an example custom Google Map https://www.google.com/maps/d/viewer?msa=0&z=11&mid=1KOVdHHEW-aaw2alcteuex4zmunk&ll=50.96764363052866%2C-0.4483580999999903

KMZ file attached:
dummy_google_kmz.zip

code:

use std::path::Path;
use kml::KmlReader;

fn main() {
    let kmz_path = Path::new("test.kmz");
    let mut kmz_reader = KmlReader::<_, f64>::from_kmz_path(kmz_path).unwrap();
    let kmz_data = kmz_reader.read().unwrap();

    println!("{:?}", kmz_data);
}

Cargo.toml:

[dependencies]
kml = "0.3"

backtrace:

thread 'main' panicked at 'Error: EscapeError(UnterminatedEntity(13..28))', /home/chris/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/kml-0.3.0/src/reader.rs:751:56
stack backtrace:
   0:     0x559af518513c - std::backtrace_rs::backtrace::libunwind::trace::hbc0dbba8e4be7fe4
                               at /usr/src/rustc-1.48.0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:96
   1:     0x559af518513c - std::backtrace_rs::backtrace::trace_unsynchronized::hd8cc0512eb4dd70a
                               at /usr/src/rustc-1.48.0/library/std/src/../../backtrace/src/backtrace/mod.rs:66
   2:     0x559af518513c - std::sys_common::backtrace::_print_fmt::h766fae1718fafbdd
                               at /usr/src/rustc-1.48.0/library/std/src/sys_common/backtrace.rs:79
   3:     0x559af518513c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha84a0cc4b4a9ee84
                               at /usr/src/rustc-1.48.0/library/std/src/sys_common/backtrace.rs:58
   4:     0x559af51b1b7f - core::fmt::write::h600ac4150cc03aef
                               at /usr/src/rustc-1.48.0/library/core/src/fmt/mod.rs:1080
   5:     0x559af517f565 - std::io::Write::write_fmt::h204ba0c32f2b9a99
                               at /usr/src/rustc-1.48.0/library/std/src/io/mod.rs:1516
   6:     0x559af5196b8d - std::sys_common::backtrace::_print::h6e0f6c74c2c2ad8f
                               at /usr/src/rustc-1.48.0/library/std/src/sys_common/backtrace.rs:61
   7:     0x559af5196b8d - std::sys_common::backtrace::print::h44d505c625eab4ff
                               at /usr/src/rustc-1.48.0/library/std/src/sys_common/backtrace.rs:48
   8:     0x559af5196b8d - std::panicking::default_hook::{{closure}}::h891d2ab61783cea8
                               at /usr/src/rustc-1.48.0/library/std/src/panicking.rs:208
   9:     0x559af5196893 - std::panicking::default_hook::h99e2d300f2614f89
                               at /usr/src/rustc-1.48.0/library/std/src/panicking.rs:227
  10:     0x559af519714f - std::panicking::rust_panic_with_hook::h1b36ee28aa35f9da
                               at /usr/src/rustc-1.48.0/library/std/src/panicking.rs:577
  11:     0x559af5185579 - std::panicking::begin_panic_handler::{{closure}}::h4b50a04380233c65
                               at /usr/src/rustc-1.48.0/library/std/src/panicking.rs:484
  12:     0x559af518528c - std::sys_common::backtrace::__rust_end_short_backtrace::hf274a9700b168e63
                               at /usr/src/rustc-1.48.0/library/std/src/sys_common/backtrace.rs:153
  13:     0x559af5196d52 - rust_begin_unwind
                               at /usr/src/rustc-1.48.0/library/std/src/panicking.rs:483
  14:     0x559af51b3e51 - core::panicking::panic_fmt::hb284f9f2db79ce48
                               at /usr/src/rustc-1.48.0/library/core/src/panicking.rs:85
  15:     0x559af51ad9c3 - core::result::unwrap_failed::h87affc05a8b0ab4b
                               at /usr/src/rustc-1.48.0/library/core/src/result.rs:1220
  16:     0x559af50e03b4 - core::result::Result<T,E>::expect::h0ed01b799c25cb4e
                               at /usr/src/rustc-1.48.0/library/core/src/result.rs:933
  17:     0x559af50ddb3d - kml::reader::KmlReader<B,T>::read_str::h03f02272c39401d2
                               at /home/chris/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/kml-0.3.0/src/reader.rs:751
  18:     0x559af50d241b - kml::reader::KmlReader<B,T>::read_placemark::h1f20ffc5c60dc37d
                               at /home/chris/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/kml-0.3.0/src/reader.rs:314
  19:     0x559af50cf88a - kml::reader::KmlReader<B,T>::read_elements::h87550ba9e30c4f65
                               at /home/chris/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/kml-0.3.0/src/reader.rs:139
  20:     0x559af50cfd0b - kml::reader::KmlReader<B,T>::read_elements::h87550ba9e30c4f65
                               at /home/chris/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/kml-0.3.0/src/reader.rs:146
  21:     0x559af50cfaac - kml::reader::KmlReader<B,T>::read_elements::h87550ba9e30c4f65
                               at /home/chris/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/kml-0.3.0/src/reader.rs:142
  22:     0x559af50dae9b - kml::reader::KmlReader<B,T>::read_kml_document::hca2ae4cd04837891
                               at /home/chris/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/kml-0.3.0/src/reader.rs:184
  23:     0x559af50ce8f2 - kml::reader::KmlReader<B,T>::read_elements::h87550ba9e30c4f65
                               at /home/chris/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/kml-0.3.0/src/reader.rs:127
  24:     0x559af50dd364 - kml::reader::KmlReader<B,T>::read::h689c2e9854e8a4c4
                               at /home/chris/.cargo/registry/src/jackfan.us.kg-1ecc6299db9ec823/kml-0.3.0/src/reader.rs:107
  25:     0x559af5103a8b - ffw::main::h88092b5e53f8c5be
                               at /home/chris/projects/ffw/src/main.rs:7
  26:     0x559af50fee1b - core::ops::function::FnOnce::call_once::h7e1b76c4a055bd16
                               at /usr/src/rustc-1.48.0/library/core/src/ops/function.rs:227
  27:     0x559af510a30e - std::sys_common::backtrace::__rust_begin_short_backtrace::h20e9080ea383d6d9
                               at /usr/src/rustc-1.48.0/library/std/src/sys_common/backtrace.rs:137
  28:     0x559af50e5321 - std::rt::lang_start::{{closure}}::h1260508dfa92c215
                               at /usr/src/rustc-1.48.0/library/std/src/rt.rs:66
  29:     0x559af5197454 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h473f4d9760584df9
                               at /usr/src/rustc-1.48.0/library/core/src/ops/function.rs:259
  30:     0x559af5197454 - std::panicking::try::do_call::h38b2d68e1990d627
                               at /usr/src/rustc-1.48.0/library/std/src/panicking.rs:381
  31:     0x559af5197454 - std::panicking::try::h6c98453927853dba
                               at /usr/src/rustc-1.48.0/library/std/src/panicking.rs:345
  32:     0x559af5197454 - std::panic::catch_unwind::hf939d3206ba7e318
                               at /usr/src/rustc-1.48.0/library/std/src/panic.rs:382
  33:     0x559af5197454 - std::rt::lang_start_internal::h3c710f42dc1fbba8
                               at /usr/src/rustc-1.48.0/library/std/src/rt.rs:51
  34:     0x559af50e52f7 - std::rt::lang_start::h89631e9ad0445e6d
                               at /usr/src/rustc-1.48.0/library/std/src/rt.rs:65
  35:     0x559af5103c0a - main
  36:     0x7fdddeee1d0a - __libc_start_main
  37:     0x559af50c70ba - _start
  38:                0x0 - <unknown>

any tips would be great :)

@pjsier
Copy link
Member

pjsier commented Mar 6, 2021

Thanks for the report! It looks like there are a few leftover calls to expect in the code that aren't handling any UTF-8 decoding issues and causing the panic. I just opened PR #2 that fixes it for me on your example file. Let me know if that change fixes it for you as well and I can go ahead and merge that and release a new version

@pjsier pjsier closed this as completed in #2 Mar 7, 2021
@obbardc
Copy link
Author

obbardc commented Mar 7, 2021

sorry for not reporting back more timely; the new version works really well! Thank you!!

@pjsier
Copy link
Member

pjsier commented Mar 7, 2021

No problem at all, I figured we were safe to make a new release when your example worked, so thanks for the detailed bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants