发布

  • fix: avoid unicode filepath suffix panic (#393)

    frostbyte_neo 发布于 2026-04-21 13:35:34 +00:00

    • fix: avoid unicode filepath suffix panic

    • fix: prevent unicode char boundary panics in all constraint functions

    The previous fix (a09292e) only guarded path_ends_with_suffix with
    path.get(start..), but three problems remained:

    1. path_ends_with_suffix: path_bytes[start - 1] reads inside a
      multi-byte char when start is a valid boundary but start-1 is not.
      Fixed by scanning backward to find the preceding ASCII byte.

    2. path_contains_segment: path[..segment_len] and path[start..end]
      slice at non-char-boundary offsets when segment is ASCII but the
      path contains multi-byte UTF-8 (Korean, etc).
      Fixed with is_char_boundary() checks before each slice.

    3. file_has_extension: same byte-offset issue for dot_pos.
      Fixed with is_char_boundary() check.

    Adds regression tests with the exact Korean filenames that caused
    panics (커리큘럼, 세부_커리큘럼_최종, 설치-및-기본-사용, etc).
    Merges upstream unicode tests (apostrophe, narrow-space mismatches).


    Co-authored-by: Dmitriy Kovalenko dmtr.kovalenko@outlook.com

    下载附件