File picker button labels show HTML entities for file names with special characters

Aperta Adatta ai principianti
#2,770 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
frontend

Direzione di ricerca

Leggi lib/filepicker-builder.ts intorno alle righe 218–241, dove vengono create le etichette predefinite dei pulsanti del selettore, e trova i test relativi alle etichette. Verifica come gettext esegue l’escape dei valori dei segnaposto e come le etichette vengono visualizzate come testo. Aggiorna le etichette in modo che i nomi contenenti apostrofi e e commerciali appaiano così come sono, quindi aggiungi un test che copra questi caratteri.

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

Descrizione

bug
Describe the bug

The file picker button labels that contain a file or folder name show HTML entities when the name contains characters like ', &, < or ", e.g. Choose Tom&#39;s folder or Copy to A &amp; B.

The labels are built with the gettext wrapper, which HTML-escapes placeholder values by default:

https://github.com/nextcloud-libraries/nextcloud-dialogs/blob/636c9a8ea2700380d4cd8d1b0b1d57d50850ab29/lib/filepicker-builder.ts#L218-L241

label = t('Choose {file}', { file: target })
// …
label: target ? t('Copy to {target}', { target }) : t('Copy'),
// …
label: target ? t('Move to {target}', { target }) : t('Move'),

The result is then rendered as plain button text (not as HTML), so the escaped entities are shown literally.

Originally reported in nextcloud/server#55191 for the "Set default folder for accepted shares" picker in the personal sharing settings, but it affects every picker using these default buttons (e.g. "Copy to …" / "Move to …" in the Files app).

To Reproduce

Found by code reading and the screenshot in nextcloud/server#55191.

  1. Create a folder named Tom's files.
  2. Open a file picker that uses the default buttons (e.g. "Move or copy" in Files) and select that folder.
  3. The button shows Copy to Tom&#39;s files.
Expected behavior

The labels show the plain name: either pass the placeholders unescaped (the labels are rendered as text, so no HTML escaping is needed there) or skip escaping for these button labels, with a test for a name containing ' and &.

Lingua principale
TypeScript
Stelle
19
Fork
10
Merge medio
17h 4m
PR unite (30g)
30

Preparare l'ambiente

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 nextcloud-libraries/nextcloud-dialogs

Tutte le issue di nextcloud-libraries/nextcloud-dialogs

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.