[Bug]: Case-insensitive replace in naming can splice at the wrong position

Open Beginner friendly
#124 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
backend

Research direction

Start in src/automation/naming.rs at replace_ci (line 56) and read how the lowercase byte offset is used to splice the original string. Add a failing test with a needle whose lowercase form changes byte length (the issue's İ -> i̇ case) next to the existing naming tests, then run cargo test for that module. Done means the replacement lands at the original-string match position and the new case passes.

Written by the indexing model from the issue text.

Description

bug

[!NOTE]
This issue was written by Claude (Claude Opus 5.5) from a code review session with @PhrolovaMoe. It was found by reading the code and hasn't been reproduced on a running server.

Version

0.40.0 (feat/desktop, 017a837b)

Area

Torrents

What happened?

replace_ci finds the needle in hay.to_lowercase() and uses that byte offset to splice the original hay (src/automation/naming.rs:56). Lowercasing can change byte lengths (İ → i̇, for example), so the offsets don't line up: the char-boundary check stops a panic, but the replacement can land in the wrong place or be skipped.

Expected behavior

Replacements happen where the match is in the original string.

Suggested fix

Match case-insensitively on the original string (e.g. a case-insensitive regex with regex::escape(needle)), or map lowercase offsets back char by char.

Dominant language
TypeScript
Stars
4
Forks
1
Avg merge
4h 49m
Merged PRs (30d)
5

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tinystream-dev/tinystream

All issues in tinystream-dev/tinystream

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.