1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-21 16:22:22 +02:00

Merge pull request #6337 from marc1706/ticket/16924

[ticket/16924] Do not double escape values inserted into config table
This commit is contained in:
Marc Alexander 2021-12-07 21:57:47 +01:00
commit ec75f1741b
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995
3 changed files with 21 additions and 3 deletions

View File

@ -170,9 +170,9 @@ class db extends config
if (!isset($this->config[$key]))
{
$sql = 'INSERT INTO ' . $this->table . ' ' . $this->db->sql_build_array('INSERT', array(
'config_name' => $this->db->sql_escape($key),
'config_value' => $this->db->sql_escape($new_value),
'is_dynamic' => ($use_cache) ? 0 : 1));
'config_name' => $key,
'config_value' => $new_value,
'is_dynamic' => $use_cache ? 0 : 1));
$this->db->sql_query($sql);
}

View File

@ -86,6 +86,17 @@ class phpbb_config_db_test extends phpbb_database_test_case
$this->cache->checkVar($this, 'config', array('foo' => '23', 'foobar' => '5'));
}
public function test_set_new_json()
{
$json_value = '{"menu":{"id":"file","value":"File"}}';
$this->config->set('foobar_json', $json_value);
$this->assertEquals($json_value, $this->config['foobar_json']);
// re-read config and populate cache
$config2 = new \phpbb\config\db($this->db, $this->cache, 'phpbb_config');
$this->cache->checkVar($this, 'config', ['foo' => '23', 'foobar_json' => $json_value]);
}
public function test_set_new_uncached()
{
$this->config->set('foobar', '5', false);

View File

@ -46,6 +46,13 @@ class phpbb_config_db_text_test extends phpbb_database_test_case
$this->assertSame('phpbb', $this->config_text->get('barz'));
}
public function test_set_new_get_json()
{
$json_value = '{"menu":{"id":"file","value":"File"}}';
$this->config_text->set('foobar_json', $json_value);
$this->assertEquals($json_value, $this->config_text->get('foobar_json'));
}
public function test_set_replace_get()
{
$this->config_text->set('foo', '24');