Control characters in run text are deleted on save, so Segment.BeginOffset and run boundaries shift after reload

オープン
#415 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
54/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
csharp, xml
領域
backend, databases

調査の方向性

Start by reading StripInvalidXmlChars in TsStringSerializer and TsStringUtils.NormalizeNfd(ITsString), then compare the suggested behavior with #414. Run the named ControlCharacterOffsetDesyncTests and the TsStringSerializerTests round-trip to confirm the offset shift. Done means serialization and normalization preserve text length by replacing invalid XML characters with U+FFFD, or the chosen input policy is covered by tests.

索引モデルが issue の本文から書いたものです。

説明

Characters XML cannot store (U+0000–U+0008, U+000B, U+000C, U+000E–U+001F, U+FFFE, U+FFFF) are accepted by the model, but TsStringSerializer silently deletes them on write (StripInvalidXmlChars). After reload, anything that stores a character index into the text points at the wrong character.

Repro (master 0bc98fb0, net462 and net8.0):

  • Take a paragraph One a<U+0001>b two. Three four. whose second segment has BeginOffset 13 ("Three"). Save, close and reopen the project. The text is now 23 characters instead of 24, and BeginOffset 13 points at "hree ". The next parse or edit misplaces analyses.
  • The same happens with a plain string: runs ab<U+0001>cd (en) + EFGH (es) serialize and deserialize with the es run starting at 4 instead of 5.

ktptOffset is not affected: it is a baseline shift in millipoints, not a character index.

Suggested fix: make writes length-preserving by replacing these characters with U+FFFD instead of deleting them, and apply the same replacement at input in TsStringUtils.NormalizeNfd(ITsString). This is the approach #414 takes for lone surrogates. Whether to replace them or reject them at input is a maintainer decision. Failing tests are ready (ControlCharacterOffsetDesyncTests, and a TsStringSerializerTests round-trip) and can come with the fix PR.

Related: #409, #412, #414.

主要言語
C#
スター
3
フォーク
15
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sillsdev/liblcm のほかの issue

sillsdev/liblcm の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。