mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 23:24:46 +02:00
Fix escaping for EnvironmentWriterTrait
(#610)
* fix escaping for EnvironmentWriterTrait * remove alphaNum from app name field * add test for `'` escaping
This commit is contained in:
parent
a946669dc8
commit
e23a4a667a
@ -92,7 +92,6 @@ class Settings extends Page implements HasForms
|
||||
TextInput::make('APP_NAME')
|
||||
->label('App Name')
|
||||
->required()
|
||||
->alphaNum()
|
||||
->default(env('APP_NAME', 'Pelican')),
|
||||
TextInput::make('APP_FAVICON')
|
||||
->label('App Favicon')
|
||||
|
@ -14,7 +14,7 @@ trait EnvironmentWriterTrait
|
||||
public function escapeEnvironmentValue(string $value): string
|
||||
{
|
||||
if (!preg_match('/^\"(.*)\"$/', $value) && preg_match('/([^\w.\-+\/])+/', $value)) {
|
||||
return sprintf('"%s"', addslashes($value));
|
||||
return sprintf('"%s"', addcslashes($value, '\\"'));
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
@ -23,6 +23,7 @@ class EnvironmentWriterTraitTest extends TestCase
|
||||
['foo', 'foo'],
|
||||
['abc123', 'abc123'],
|
||||
['val"ue', '"val\"ue"'],
|
||||
['val\'ue', '"val\'ue"'],
|
||||
['my test value', '"my test value"'],
|
||||
['mysql_p@assword', '"mysql_p@assword"'],
|
||||
['mysql_p#assword', '"mysql_p#assword"'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user