bigpresh / bigpresh/Dancer-Plugin-EscapeHTML

Clone references before escaping?

Aperta
#4 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Perl
Stelle
4
Fork
3
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

As originally discovered in http://www.backup-manager.org/pipermail/dancer-users/2012-April/002424.html :

When `automatic_escaping` is enabled, we recursively encode HTML entities in template params, following references.

Since the app's settings are automatically passed to the template by `Dancer::Template::Abstract`, stored as a reference to the real settings hashref, we can inadvertently go HTML-encoding stuff in the app's actual settings.

A partial fix is for Dancer to clone the settings rather than storing an actual reference, but of course that still means the problem can occur in other cases.

For example:

``` perl
get '/' => sub {
my $foo = { foo => '' };
my $html = template 'bar', { foo => $foo };
# $foo->{foo} has been changed to <Foo>
};
```

Probably a safer fix is for `_encode` to automatically clone any reference it's about to change before making changes. This would need some refactoring in `_encode` to assume that it's starting with a hashref (which it will be) and to pass on both the key and the value each time, rather than simply passing the reference to the value when recursing.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia dal punto di ingresso `_encode` descritto nell’issue e segui il modo in cui elabora ricorsivamente i parametri dei template e i riferimenti. Verifica l’esempio che coinvolge `Dancer::Template::Abstract` e conferma che l’escaping non modifica più le impostazioni originali o i riferimenti `$foo`; aggiungi o esegui i test esistenti pertinenti, se presenti.

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

Valutazione

Stack tecnologico
perl
Ambito
backend, security
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
28/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.