BUG: CharacterSpaceConverter introduces whitespace holes and trailing whitespace

オープン 初心者向け
#4,043 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@Kaap10 がすでに取り組んでいます。

2026年11月7日 から。

  • #4044 @Kaap10 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

PyRIT のソースコードから CharacterSpaceConverter とそのテストを見つけてください。コンバーターの実装を読み、まず既存のコンバーターテストを実行してください。その後、単語間の句読点、短縮形、末尾の句読点を対象とするテストを追加してください。句読点がスペースの挿入前に取り除かれ、出力が例と一致し、句読点パターンがモジュールレベルで一度だけコンパイルされれば完了です。

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

説明

Describe the bug

CharacterSpaceConverter spaces out characters with " ".join(prompt) before removing punctuation with re.sub(...). This order of operations introduces whitespace artifacts:

  1. Stripping punctuation leaves empty character "holes", producing 4 spaces between words (e.g., "Hello, world" -> "H e l l o w o r l d" instead of the standard 3-space inter-word spacing "H e l l o w o r l d").
  2. Contractions or mid-word punctuation leave double spaces (e.g., "How's" -> "H o w s" instead of "H o w s").
  3. Trailing punctuation leaves unwanted trailing whitespace (e.g., "hello!" -> "h e l l o ").

Additionally, the punctuation regex is recompiled on every invocation of convert_async rather than precompiled at module level.

Steps/Code to Reproduce
import asyncio
from pyrit.converter import CharacterSpaceConverter

async def main():
    converter = CharacterSpaceConverter()
    res1 = await converter.convert_async(prompt="hello!")
    print(repr(res1.output_text))  # prints 'h e l l o ' with trailing space

    res2 = await converter.convert_async(prompt="Hello, world! How's everything?")
    print(repr(res2.output_text))  # prints 'H e l l o    w o r l d    H o w  s   e v e r y t h i n g '

asyncio.run(main())
Expected Results

Punctuation should be stripped prior to character spacing so spacing remains uniform without artificial gaps or trailing whitespace:

  • "hello!" -> 'h e l l o'
  • "Hello, world! How's everything?" -> 'H e l l o w o r l d H o w s e v e r y t h i n g'
Actual Results
  • 'h e l l o '
  • 'H e l l o w o r l d H o w s e v e r y t h i n g '
Versions
  • OS: Windows 11
  • Python version: 3.12
  • PyRIT version: main
主要言語
Python
スター
4.7k
フォーク
1k
平均マージ
2日 4時間
マージ済み PR(30日)
510

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

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

microsoft/PyRIT のほかの issue

microsoft/PyRIT の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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