Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

BUG: LeetspeakConverter ignores uppercase and multi-character custom_substitutions keys and fails on empty replacement lists

Chiusa
#3,293 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@ShivamSharma43 ci sta già lavorando.

Dal 18/10/2026.

  • #3295 di @ShivamSharma43 — integrata

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
tooling

Direzione di ricerca

Read LeetspeakConverter and its convert_word_async method, then run the reproduction in the issue for uppercase, multi-character, and empty-list substitutions. Done means valid mappings produce the expected output and mappings that cannot be applied raise ValueError at construction; a linked pull request is already open.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

LeetspeakConverter does not validate custom_substitutions, and convert_word_async looks each character up as char.lower(). As a result:

  • An uppercase key such as {"A": ["4"]} never matches, so the substitution is silently ignored, for both uppercase and lowercase letters in the prompt.
  • A multi-character key such as {"th": ["7"]} never matches either, because the prompt is substituted one character at a time.
  • An empty replacement list such as {"e": []} is accepted, then fails on the first matching character with IndexError: list index out of range (deterministic mode) or IndexError: Cannot choose from an empty sequence (random mode).

The defaults use lowercase single-character keys, so only custom substitutions are affected.

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

async def main():
    for custom_substitutions in ({"A": ["4"], "T": ["7"]}, {"th": ["7"]}, {"e": []}):
        converter = LeetspeakConverter(custom_substitutions=custom_substitutions)
        try:
            result = await converter.convert_async(prompt="Let that be")
            print(custom_substitutions, repr(result.output_text))
        except Exception as e:
            print(custom_substitutions, f"{type(e).__name__}: {e}")

asyncio.run(main())
Expected Results

{"A": ["4"], "T": ["7"]} converts Let that be to Le7 7h47 be, and the other two raise ValueError when the converter is created, since those mappings can never be applied.

Actual Results
{'A': ['4'], 'T': ['7']} 'Let that be'
{'th': ['7']} 'Let that be'
{'e': []} IndexError: list index out of range
Screenshots

N/A

Versions
  • OS: Windows 11
  • Python version: 3.11.9
  • PyRIT version: installed from main (5b594e00) in editable mode
Lingua principale
Python
Stelle
4.6k
Fork
962
Merge medio
2g 16h
PR unite (30g)
367

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/PyRIT

Tutte le issue di microsoft/PyRIT

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.