jameslittle230 / stork

🔎 Impossibly fast web search, made for static sites.
https://stork-search.net
Apache License 2.0
2.73k stars 56 forks source link

Build search index on .md with specific list content crashes #290

Closed lambdaJasonYang closed 2 years ago

lambdaJasonYang commented 2 years ago

./stork-ubuntu-20-04 build --input "./docs/searchindex.toml" --output "./docs/storksearch.st"

Crashes when building a search index on markdown files with specific content:

Fails

---
title: Something
tags: test
---

1. 

something below, there is a space immediately after the 1. above  

Works

---
title: Something
tags: test
---

1.

something below, there is no space immediately after the 1. above  

with space and no text below:

---
title: Something
tags: test
---

1. 

without space and no text below:

---
title: Something
tags: test
---

1.

Stack trace

./stork-ubuntu-20-04 build --input "./docs/searchindex.toml" --output "./docs/storksearch.st"  
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/markdown-0.3.0/src/parser/block/ordered_list.rs:88:44
stack backtrace:
   0:     0x564a1a5b21ba - std::backtrace_rs::backtrace::libunwind::trace::h91c465e73bf6c785
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x564a1a5b21ba - std::backtrace_rs::backtrace::trace_unsynchronized::hae9da36f5d58b5f3
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x564a1a5b21ba - std::sys_common::backtrace::_print_fmt::h7f499fa126a7effb
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x564a1a5b21ba - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3e2b509ce2ce6007
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x564a1a42243c - core::fmt::write::h753c7571fa063ecb
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/fmt/mod.rs:1168:17
   5:     0x564a1a58c771 - std::io::Write::write_fmt::h2815c0519c99ba09
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/io/mod.rs:1660:15
   6:     0x564a1a5b3302 - std::sys_common::backtrace::_print::h64941a6fc8b0ed9b
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x564a1a5b3302 - std::sys_common::backtrace::print::hcf25e43e1a9b0766
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x564a1a5b3302 - std::panicking::default_hook::{{closure}}::h78d3e6cf97fc623d
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:211:50
   9:     0x564a1a5b40cc - std::panicking::default_hook::hda898f8d3ad1a5ae
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:228:9
  10:     0x564a1a5b40cc - std::panicking::rust_panic_with_hook::h1a5ea2d6c23051aa
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:606:17
  11:     0x564a1a5b3bc8 - std::panicking::begin_panic_handler::{{closure}}::h07f549390938b73f
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:502:13
  12:     0x564a1a5b3b46 - std::sys_common::backtrace::__rust_end_short_backtrace::h5ec3758a92cfb00d
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:139:18
  13:     0x564a1a5b3b02 - rust_begin_unwind
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
  14:     0x564a1a3c4770 - core::panicking::panic_fmt::h3a79a6a99affe1d5
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
  15:     0x564a1a3c4731 - core::panicking::panic_bounds_check::h449d4ff4d992b84f
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:84:5
  16:     0x564a1a496782 - markdown::parser::block::ordered_list::parse_ordered_list::ha2240ce7155e8c96
  17:     0x564a1a49015a - markdown::parser::block::parse_blocks::h69ebf400fe10dcf3
  18:     0x564a1a6499f7 - stork_lib::index_v3::build::fill_intermediate_entries::fill_intermediate_entries::hadfe91832a866366
  19:     0x564a1a67486d - stork_lib::build_index::hf7578b4227e918d1
  20:     0x564a1a5ca887 - stork::build_handler::h57707a42ac536792
  21:     0x564a1a5c879e - stork::main::h211f0b5ffbc811e2
  22:     0x564a1a5c6eda - std::sys_common::backtrace::__rust_begin_short_backtrace::h48fbb2cf1a93dafc
  23:     0x564a1a5c7d1a - main
  24:     0x7fd0887d67fd - __libc_start_main
                               at ./csu/../csu/libc-start.c:332:16
  25:     0x564a1a3d3c1e - _start
  26:                0x0 - <unknown>
jameslittle230 commented 2 years ago

Oh no! Thanks for the bug report. I'll investigate this and make sure it's fixed for the next release.