facebookincubator / fastmod

A fast partial replacement for the codemod tool
Apache License 2.0
1.68k stars 42 forks source link

Panic when replacing next to a unicode character #26

Closed teor2345 closed 3 years ago

teor2345 commented 3 years ago

When I run the following commands:

git clone https://github.com/ZcashFoundation/zebra.git
cd zebra
git checkout b618f5b5
yes n | RUST_BACKTRACE=full fastmod --extensions rs,toml,md 'sapling' 'canopy'

Which modify the line (note unicode quotation marks):

/// test network, the Human-Readable Part is “zviewtestsapling”.

I get a panic:

thread 'main' panicked at 'byte index 24841 is not a char boundary; it is inside '”' (bytes 24840..24843) of `//! Key types.
//!
//! "The spend authorizing key ask, proof authorizing key (ak, nsk),
//! full viewing key (ak, nk, ovk), incoming viewing key ivk, and each
//! diversified payment address addr_d = (d, pk_d ) are derived from sk,
//! as described in [Sap`[...]', /build/rustc-1.45.2-src/src/libcore/str/mod.rs:2052:47
stack backtrace:
   0:     0x5596d4a5ff43 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8e44e3bad104136e
   1:     0x5596d4a912dd - core::fmt::write::he8cb6d64ed166147
   2:     0x5596d4a73cf7 - std::io::Write::write_fmt::hf25ce96005919ce6
   3:     0x5596d4a6ca50 - std::panicking::default_hook::{{closure}}::hf8bcda2c877e2dcc
   4:     0x5596d4a6c764 - std::panicking::default_hook::h0602fc6a3744f2c1
   5:     0x5596d4a6d077 - std::panicking::rust_panic_with_hook::h7b83b0fe7900eb7a
   6:     0x5596d4a6cc7b - rust_begin_unwind
   7:     0x5596d4a90fc1 - core::panicking::panic_fmt::h61e03e91a1a8868a
   8:     0x5596d4a9909a - core::str::slice_error_fail::hefd104cb0d72240c
   9:     0x5596d48c5f49 - core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::RangeFrom<usize>>::index::{{closure}}::h58d54a1cca6b09df
  10:     0x5596d48ce3e4 - fastmod::fastmod::hab3ce024a00b140c
  11:     0x5596d48cee73 - fastmod::main::h61f268b40af6022f
  12:     0x5596d48db943 - std::rt::lang_start::{{closure}}::hccb3d6d4b12ae437
  13:     0x5596d4a6d427 - std::rt::lang_start_internal::h7d1b27a1580794aa
  14:     0x5596d48cf052 - main
  15:     0x7ff62902bcbd - __libc_start_main
  16:     0x5596d48b71fa - _start
  17:                0x0 - <unknown>