Skip to content

Commit

Permalink
Memoized more translations
Browse files Browse the repository at this point in the history
  • Loading branch information
sybrew committed Aug 8, 2023
1 parent 6a04e02 commit 4d8e263
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 88 deletions.
74 changes: 20 additions & 54 deletions language/pro-mime-types.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the GPLv3.
msgid ""
msgstr ""
"Project-Id-Version: Pro Mime Types - Manage file media types 2.0.0\n"
"Project-Id-Version: Pro Mime Types - Manage file media types 2.0.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/pro-mime-types\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2023-05-09T01:54:17+00:00\n"
"POT-Creation-Date: 2023-08-08T15:06:49+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.7.1\n"
"X-Domain: pro-mime-types\n"
Expand All @@ -34,7 +34,7 @@ msgstr ""
msgid "https://cyberwire.nl/"
msgstr ""

#: inc/admin.php:198
#: inc/admin.php:197
msgid "Sorry, you are not allowed to update Pro Mime Types settings."
msgstr ""

Expand Down Expand Up @@ -86,81 +86,47 @@ msgid_plural "Miscellaneous <span class=\"count\">(%s)</span>"
msgstr[0] ""
msgstr[1] ""

#: promimetypes.php:242
#: promimetypes.php:243
#: promimetypes.php:245
#: promimetypes.php:247
#: promimetypes.php:249
#: promimetypes.php:255
#: promimetypes.php:260
#: promimetypes.php:261
#: promimetypes.php:262
#: promimetypes.php:263
#: promimetypes.php:264
#: promimetypes.php:265
#: promimetypes.php:267
#: promimetypes.php:271
#: promimetypes.php:272
#: promimetypes.php:273
#: promimetypes.php:274
#: promimetypes.php:276
#: promimetypes.php:277
#: promimetypes.php:279
#: promimetypes.php:281
#: promimetypes.php:313
#: promimetypes.php:314
#: promimetypes.php:315
#: promimetypes.php:178
msgid "XML file formats can be executed by the browser when interpreted in HTML."
msgstr ""

#: promimetypes.php:179
msgid "Can contain macros which office software may execute."
msgstr ""

#: promimetypes.php:244
#: promimetypes.php:246
#: promimetypes.php:266
#: promimetypes.php:268
#: promimetypes.php:275
#: promimetypes.php:278
#: promimetypes.php:280
#: promimetypes.php:282
#: promimetypes.php:304
#: promimetypes.php:307
#: promimetypes.php:316
msgid "XML file formats can be executed by the browser when interpreted as HTML."
#: promimetypes.php:180
msgid "Compressed file format, can contain unwanted stuff."
msgstr ""

#: promimetypes.php:250
msgid "Can exploit vulnerabilities when opened in browsers."
#: promimetypes.php:211
msgid "XML file formats can be executed by the browser when interpreted in HTML. SVG is always interpreted in HTML."
msgstr ""

#: promimetypes.php:294
#: promimetypes.php:295
#: promimetypes.php:297
#: promimetypes.php:298
#: promimetypes.php:299
#: promimetypes.php:300
msgid "Compressed file format, can contain unwanted stuff."
#: promimetypes.php:255
msgid "Can exploit vulnerabilities when opened in browsers."
msgstr ""

#: promimetypes.php:296
#: promimetypes.php:301
msgid "Compressed file format, can contain unwanted stuff. Executes in browser."
msgstr ""

#: promimetypes.php:303
#: promimetypes.php:308
msgid "CSS can import external resources in the browser."
msgstr ""

#: promimetypes.php:305
#: promimetypes.php:310
msgid "Can run in iframes through shortcodes. Can import javascript. Can import CSS."
msgstr ""

#: promimetypes.php:306
#: promimetypes.php:311
msgid "Can execute code in browser."
msgstr ""

#: promimetypes.php:311
#: promimetypes.php:316
msgid "Can be executed by some servers."
msgstr ""

#: promimetypes.php:312
#: promimetypes.php:317
msgid "Can install unwanted software."
msgstr ""

Expand Down
66 changes: 34 additions & 32 deletions promimetypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ function get_allowed_mime_types_settings() {
*/
function _define_supported_mime_types() {

$is_svg_i18n = \__( 'XML file formats can be executed by the browser when interpreted as HTML.', 'pro-mime-types' );
$is_svg_i18n = \__( 'XML file formats can be executed by the browser when interpreted in HTML.', 'pro-mime-types' );
$is_macro_i18n = \__( 'Can contain macros which office software may execute.', 'pro-mime-types' );
$is_compressed_i18n = \__( 'Compressed file format, can contain unwanted stuff.', 'pro-mime-types' );

/**
* @since 2.0.0
Expand Down Expand Up @@ -206,7 +208,7 @@ function _define_supported_mime_types() {
[ 'ico', 'image/x-icon', MIME_DANGER_LEVEL['safe'], '', 'image' ],
[ 'jpg|jpeg|jpe|jif|jfif', 'image/jpeg', MIME_DANGER_LEVEL['safe'], '', 'image' ],
[ 'png', 'image/png', MIME_DANGER_LEVEL['safe'], '', 'image' ],
[ 'svg', 'image/svg+xml', MIME_DANGER_LEVEL['high-risk'], $is_svg_i18n, 'image' ],
[ 'svg', 'image/svg+xml', MIME_DANGER_LEVEL['dangerous'], \__( 'XML file formats can be executed by the browser when interpreted in HTML. SVG is always interpreted in HTML.', 'pro-mime-types' ), 'image' ], // Dangerous: This XML type is always executed.
[ 'tif|tiff', 'image/tiff', MIME_DANGER_LEVEL['safe'], '', 'image' ],
[ 'webp', 'image/webp', MIME_DANGER_LEVEL['safe'], '', 'image' ],

Expand Down Expand Up @@ -242,46 +244,46 @@ function _define_supported_mime_types() {
[ 'wmx', 'video/x-ms-wmx', MIME_DANGER_LEVEL['safe'], '', 'video' ],

// Document formats.
[ 'doc', 'application/msword', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'document' ],
[ 'docm', 'application/vnd.ms-word.document.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'document' ],
[ 'doc', 'application/msword', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'document' ],
[ 'docm', 'application/vnd.ms-word.document.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'document' ],
[ 'docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', MIME_DANGER_LEVEL['low-risk'], $is_svg_i18n, 'document' ],
[ 'dotm', 'application/vnd.ms-word.template.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'document' ],
[ 'dotm', 'application/vnd.ms-word.template.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'document' ],
[ 'dotx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', MIME_DANGER_LEVEL['low-risk'], $is_svg_i18n, 'document' ],
[ 'odt', 'application/vnd.oasis.opendocument.text', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'document' ],
[ 'odt', 'application/vnd.oasis.opendocument.text', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'document' ],
[ 'oxps', 'application/oxps', MIME_DANGER_LEVEL['safe'], '', 'document' ],
[ 'pages', 'application/vnd.apple.pages', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'document' ],
[ 'pages', 'application/vnd.apple.pages', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'document' ],
[ 'pdf', 'application/pdf', MIME_DANGER_LEVEL['low-risk'], \__( 'Can exploit vulnerabilities when opened in browsers.', 'pro-mime-types' ), 'document' ],
[ 'psd', 'image/vnd.adobe.photoshop', MIME_DANGER_LEVEL['safe'], '', 'document' ],
[ 'ai', 'application/postscript', MIME_DANGER_LEVEL['safe'], '', 'document' ],
[ 'rtf', 'application/rtf', MIME_DANGER_LEVEL['safe'], '', 'document' ],
[ 'wri', 'application/vnd.ms-write', MIME_DANGER_LEVEL['safe'], '', 'document' ],
[ 'wp|wpd', 'application/wordperfect', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'document' ],
[ 'wp|wpd', 'application/wordperfect', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'document' ],
[ 'xcf', 'image/x-xcf', MIME_DANGER_LEVEL['safe'], '', 'document' ],
[ 'xps', 'application/vnd.ms-xpsdocument', MIME_DANGER_LEVEL['safe'], '', 'document' ],

// Spreadsheet formats.
[ 'numbers', 'application/vnd.apple.numbers', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'spreadsheet' ],
[ 'ods', 'application/vnd.oasis.opendocument.spreadsheet', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'spreadsheet' ],
[ 'xla|xls|xlt|xlw', 'application/vnd.ms-excel', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'spreadsheet' ],
[ 'xlam', 'application/vnd.ms-excel.addin.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'spreadsheet' ],
[ 'xlsb', 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'spreadsheet' ],
[ 'xlsm', 'application/vnd.ms-excel.sheet.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'spreadsheet' ],
[ 'numbers', 'application/vnd.apple.numbers', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'spreadsheet' ],
[ 'ods', 'application/vnd.oasis.opendocument.spreadsheet', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'spreadsheet' ],
[ 'xla|xls|xlt|xlw', 'application/vnd.ms-excel', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'spreadsheet' ],
[ 'xlam', 'application/vnd.ms-excel.addin.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'spreadsheet' ],
[ 'xlsb', 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'spreadsheet' ],
[ 'xlsm', 'application/vnd.ms-excel.sheet.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'spreadsheet' ],
[ 'xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', MIME_DANGER_LEVEL['low-risk'], $is_svg_i18n, 'spreadsheet' ],
[ 'xltm', 'application/vnd.ms-excel.template.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'spreadsheet' ],
[ 'xltm', 'application/vnd.ms-excel.template.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'spreadsheet' ],
[ 'xltx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', MIME_DANGER_LEVEL['low-risk'], $is_svg_i18n, 'spreadsheet' ],

// Interactive formats.
[ 'key', 'application/vnd.apple.keynote', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'interactive' ],
[ 'odp', 'application/vnd.oasis.opendocument.presentation', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'interactive' ],
[ 'pot|pps|ppt', 'application/vnd.ms-powerpoint', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'interactive' ],
[ 'potm', 'application/vnd.ms-powerpoint.template.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'interactive' ],
[ 'key', 'application/vnd.apple.keynote', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'interactive' ],
[ 'odp', 'application/vnd.oasis.opendocument.presentation', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'interactive' ],
[ 'pot|pps|ppt', 'application/vnd.ms-powerpoint', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'interactive' ],
[ 'potm', 'application/vnd.ms-powerpoint.template.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'interactive' ],
[ 'potx', 'application/vnd.openxmlformats-officedocument.presentationml.template', MIME_DANGER_LEVEL['low-risk'], $is_svg_i18n, 'interactive' ],
[ 'ppam', 'application/vnd.ms-powerpoint.addin.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'interactive' ],
[ 'ppsm', 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'interactive' ],
[ 'ppam', 'application/vnd.ms-powerpoint.addin.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'interactive' ],
[ 'ppsm', 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'interactive' ],
[ 'ppsx', 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', MIME_DANGER_LEVEL['low-risk'], $is_svg_i18n, 'interactive' ],
[ 'pptm', 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'interactive' ],
[ 'pptm', 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'interactive' ],
[ 'pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', MIME_DANGER_LEVEL['low-risk'], $is_svg_i18n, 'interactive' ],
[ 'sldm', 'application/vnd.ms-powerpoint.slide.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'interactive' ],
[ 'sldm', 'application/vnd.ms-powerpoint.slide.macroEnabled.12', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'interactive' ],
[ 'sldx', 'application/vnd.openxmlformats-officedocument.presentationml.slide', MIME_DANGER_LEVEL['low-risk'], $is_svg_i18n, 'interactive' ],

// Text formats.
Expand All @@ -294,13 +296,13 @@ function _define_supported_mime_types() {
[ 'vtt', 'text/vtt', MIME_DANGER_LEVEL['safe'], '', 'text' ],

// Archive formats.
[ '7z', 'application/x-7z-compressed', MIME_DANGER_LEVEL['high-risk'], \__( 'Compressed file format, can contain unwanted stuff.', 'pro-mime-types' ), 'archive' ],
[ 'cab', 'application/vnd.ms-cab-compressed', MIME_DANGER_LEVEL['high-risk'], \__( 'Compressed file format, can contain unwanted stuff.', 'pro-mime-types' ), 'archive' ],
[ '7z', 'application/x-7z-compressed', MIME_DANGER_LEVEL['high-risk'], $is_compressed_i18n, 'archive' ],
[ 'cab', 'application/vnd.ms-cab-compressed', MIME_DANGER_LEVEL['high-risk'], $is_compressed_i18n, 'archive' ],
[ 'gz|gzip', 'application/x-gzip', MIME_DANGER_LEVEL['dangerous'], \__( 'Compressed file format, can contain unwanted stuff. Executes in browser.', 'pro-mime-types' ), 'archive' ],
[ 'img|2mg|smi|dmg', 'application/x-apple-diskimage', MIME_DANGER_LEVEL['high-risk'], \__( 'Compressed file format, can contain unwanted stuff.', 'pro-mime-types' ), 'archive' ],
[ 'rar', 'application/rar', MIME_DANGER_LEVEL['high-risk'], \__( 'Compressed file format, can contain unwanted stuff.', 'pro-mime-types' ), 'archive' ],
[ 'tar', 'application/x-tar', MIME_DANGER_LEVEL['high-risk'], \__( 'Compressed file format, can contain unwanted stuff.', 'pro-mime-types' ), 'archive' ],
[ 'zip', 'application/zip', MIME_DANGER_LEVEL['high-risk'], \__( 'Compressed file format, can contain unwanted stuff.', 'pro-mime-types' ), 'archive' ],
[ 'img|2mg|smi|dmg', 'application/x-apple-diskimage', MIME_DANGER_LEVEL['high-risk'], $is_compressed_i18n, 'archive' ],
[ 'rar', 'application/rar', MIME_DANGER_LEVEL['high-risk'], $is_compressed_i18n, 'archive' ],
[ 'tar', 'application/x-tar', MIME_DANGER_LEVEL['high-risk'], $is_compressed_i18n, 'archive' ],
[ 'zip', 'application/zip', MIME_DANGER_LEVEL['high-risk'], $is_compressed_i18n, 'archive' ],

// Code formats.
[ 'css', 'text/css', MIME_DANGER_LEVEL['high-risk'], \__( 'CSS can import external resources in the browser.', 'pro-mime-types' ), 'code' ],
Expand All @@ -313,9 +315,9 @@ function _define_supported_mime_types() {
// Misc application formats.
[ 'class', 'application/x-httpd-java', MIME_DANGER_LEVEL['high-risk'], \__( 'Can be executed by some servers.', 'pro-mime-types' ), 'misc' ],
[ 'exe', 'application/x-msdownload', MIME_DANGER_LEVEL['dangerous'], \__( 'Can install unwanted software.', 'pro-mime-types' ), 'misc' ],
[ 'mdb', 'application/vnd.ms-access', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'misc' ],
[ 'mpp', 'application/vnd.ms-project', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'misc' ],
[ 'odb', 'application/vnd.oasis.opendocument.database', MIME_DANGER_LEVEL['low-risk'], \__( 'Can contain macros which office software may execute.', 'pro-mime-types' ), 'misc' ],
[ 'mdb', 'application/vnd.ms-access', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'misc' ],
[ 'mpp', 'application/vnd.ms-project', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'misc' ],
[ 'odb', 'application/vnd.oasis.opendocument.database', MIME_DANGER_LEVEL['low-risk'], $is_macro_i18n, 'misc' ],
[ 'odc', 'application/vnd.oasis.opendocument.chart', MIME_DANGER_LEVEL['low-risk'], $is_svg_i18n, 'misc' ],
[ 'odf', 'application/vnd.oasis.opendocument.formula', MIME_DANGER_LEVEL['safe'], '', 'misc' ],
[ 'odg', 'application/vnd.oasis.opendocument.graphics', MIME_DANGER_LEVEL['safe'], '', 'misc' ],
Expand Down
5 changes: 3 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ If you find an issue, please open a [support topic](https://wordpress.org/suppor

= 2.0.1 =

* `.svg` was inattentively marked as a "safe" file extension, which it's not. Consider using the [Safe SVG plugin](https://wordpress.org/plugins/safe-svg/) to sanitize SVG uploads (you must still allow them via Pro Mime Types). If you do not use SVGs, you should disallow it being uploaded.
* Improved performance by caching repeated translations.
* Changed: `.svg` was inattentively marked as a "safe" file extension, which it's not. Consider using the [Safe SVG plugin](https://wordpress.org/plugins/safe-svg/) to sanitize SVG uploads (you must still allow them via Pro Mime Types). If you do not use SVGs, you should disallow it from being uploaded.
* Improved: The plugin is faster now since it now memoizes repeated translations.
* Updated: New translations are available.

= 2.0.0 =

Expand Down

0 comments on commit 4d8e263

Please sign in to comment.