Skip to content

panic at /src/display/style.rs for XML file with UTF-8 #865

@dvquentincarrel

Description

@dvquentincarrel

Hello, I've started using difftastic recently and came upon a commit that couldn't be diffed.
The commit contains changes to XML files with UTF-8 in them.
I'm using version 0.64.0
I've tried with and without the <?xml version="1.0" encoding="utf-8"?> but the result is the same.
I cannot include the code source, but I've managed to reproduce it by diffing the following self-contained snippets:

<data>
    Algo pour vérifier qu'il n'y a pas de doublons dans les origins importés
    car ce champ doit être unique
</data>
<data>
    Algo pour vérifier qu'il n'y a pas de doublons dans les origins importés
</data>

Here's a screenshot of the setup and it happening:
Image

The full error message is the following:

thread 'main' panicked at src/display/style.rs:61:7:
byte index 23 is not a char boundary; it is inside 'ê' (bytes 22..24) of `    car ce champ doit être unique`
stack backtrace:
   0:     0x561153890bd1 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h41751d2af6c8033a
   1:     0x5611536a7dcc - core::fmt::write::h99465148a27e4883
   2:     0x56115388bb4e - std::io::Write::write_fmt::hee8dfd57bd179ab2
   3:     0x5611538909b4 - std::sys_common::backtrace::print::h55694121c2ddf918
   4:     0x5611538921c4 - std::panicking::default_hook::{{closure}}::h29cbe3da3891b0b0
   5:     0x561153891ee1 - std::panicking::default_hook::h881e76b2b8c74280
   6:     0x5611538926bb - std::panicking::rust_panic_with_hook::hcc36e25b6e33969c
   7:     0x5611538925ce - std::panicking::begin_panic_handler::{{closure}}::ha415efb0f69f41f9
   8:     0x5611538910a6 - std::sys_common::backtrace::__rust_end_short_backtrace::h395fe90f99451e4e
   9:     0x561153892372 - rust_begin_unwind
  10:     0x5611535f1595 - core::panicking::panic_fmt::h452a83e54ecd764e
  11:     0x5611536aafec - core::str::slice_error_fail_rt::h8fc679fd0f77439d
  12:     0x5611535f1d07 - core::str::slice_error_fail::h4754d574702f62bb
  13:     0x561153746ee2 - difft::display::style::apply_colors::hecb35b4ceefeea98
  14:     0x561153702a93 - difft::display::side_by_side::print::h677d32a5b8964feb
  15:     0x56115373d128 - difft::print_diff_result::hf82dfa4fcf6d818d
  16:     0x561153737a35 - difft::main::h3e046c6acb609498
  17:     0x5611536e3c53 - std::sys_common::backtrace::__rust_begin_short_backtrace::h4f2337e25629c1c2
  18:     0x561153722629 - std::rt::lang_start::{{closure}}::h3d4db863b92df6e3
  19:     0x561153883fbf - std::rt::lang_start_internal::h2d6a60ec944b523d
  20:     0x56115373d6a5 - main
  21:     0x7fc8c4a29d90 - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  22:     0x7fc8c4a29e40 - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:392:3
  23:     0x56115360fc15 - _start
  24:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions