Skip to content

Commit

Permalink
Fixed usage of some browser transformations
Browse files Browse the repository at this point in the history
Fixes #13478

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed Jul 18, 2017
1 parent 300cc8b commit b778885
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 11 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ phpMyAdmin - ChangeLog
- issue #13468 Avoid breakage if set_time_limit is disabled
- issue #13471 Fail if ini_set/ini_get are disabled
- issue #13436 Automatically connect using SSL when server is configured so
- issue #13478 Fixed usage of some browser transformations

4.7.2 (2017-06-29)
- issue #13314 Make theme selection keep current server
Expand Down
22 changes: 11 additions & 11 deletions libraries/transformations.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,25 +204,25 @@ function PMA_getTransformationName($file)
/**
* Fixups old MIME or tranformation name to new one
*
* - applies some hardcoded fixups
* - adds spaces after _ and numbers
* - capitalizes words
* - removes back spaces
*
* @param string $value Value to fixup
*
* @return string
*/
function PMA_fixupMIME($value)
{
$delimiter_space = '- ';
$delimiter = "_";
$value = str_replace("jpeg", "JPEG", $value);
$value = str_replace("png", "PNG", $value);
$value = str_replace(
array("jpeg", "png"), array("JPEG", "PNG"), $value
);
return str_replace(
$delimiter_space,
$delimiter,
' ',
'',
ucwords(
str_replace(
$delimiter,
$delimiter_space,
$value
)
preg_replace('/([0-9_]+)/', '$1 ', $value)
)
);
}
Expand Down
33 changes: 33 additions & 0 deletions test/libraries/PMA_transformation_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,37 @@ public function testClearTransformations()
$actual
);
}

/**
* @dataProvider fixupData
*/
public function testFixup($value, $expected)
{
$this->assertEquals(
$expected,
PMA_fixupMIME($value)
);
}

public function fixupData()
{
return array(
array(
'text_plain_bool2text.php',
'Text_Plain_Bool2Text.php'
),
array(
'application_octetstream_download.php',
'Application_Octetstream_Download.php'
),
array(
'text_plain_json.php',
'Text_Plain_Json.php'
),
array(
'image_jpeg_link.php',
'Image_JPEG_Link.php'
),
);
}
}

0 comments on commit b778885

Please sign in to comment.