Converter for Media – Optimize images | Convert WebP & AVIF - Version 1.0.3

Version Description

(2019-06-26) = * Security changes

Download this release

Release Info

Developer mateuszgbiorczyk
Plugin Icon 128x128 Converter for Media – Optimize images | Convert WebP & AVIF
Version 1.0.3
Comparing to
See all releases

Code changes from version 1.0.2 to 1.0.3

app/Settings/Save.php CHANGED
@@ -15,7 +15,8 @@
15
 
16
  private function saveConfig()
17
  {
18
- if (!isset($_POST['webpc_save'])) return;
 
19
 
20
  $values = $this->getValues();
21
  $this->saveOption('webpc_settings', $values);
@@ -30,6 +31,16 @@
30
  $name = $option['name'];
31
  $values[$name] = isset($_POST[$name]) ? $_POST[$name] : (($option['type'] === 'checkbox') ? [] : null);
32
  }
 
 
 
 
 
 
 
 
 
 
33
  return $values;
34
  }
35
 
15
 
16
  private function saveConfig()
17
  {
18
+ if (!isset($_POST['webpc_save']) || !isset($_REQUEST['_wpnonce'])
19
+ || !wp_verify_nonce($_REQUEST['_wpnonce'], 'webpc-save')) return;
20
 
21
  $values = $this->getValues();
22
  $this->saveOption('webpc_settings', $values);
31
  $name = $option['name'];
32
  $values[$name] = isset($_POST[$name]) ? $_POST[$name] : (($option['type'] === 'checkbox') ? [] : null);
33
  }
34
+ $values = $this->sanitizeValues($values);
35
+ return $values;
36
+ }
37
+
38
+ private function sanitizeValues($values)
39
+ {
40
+ foreach ($values as $index => $value) {
41
+ if (is_array($value)) $values[$index] = array_map('sanitize_text_field', $value);
42
+ else $values[$index] = sanitize_text_field($value);
43
+ }
44
  return $values;
45
  }
46
 
readme.txt CHANGED
@@ -89,6 +89,9 @@ If you are using a CDN server, find one that automatically converts images to We
89
 
90
  == Changelog ==
91
 
 
 
 
92
  = 1.0.2 (2019-06-25) =
93
  * Tab in settings page about server configuration
94
  * Modification of error messages
89
 
90
  == Changelog ==
91
 
92
+ = 1.0.3 (2019-06-26) =
93
+ * Security changes
94
+
95
  = 1.0.2 (2019-06-25) =
96
  * Tab in settings page about server configuration
97
  * Modification of error messages
resources/views/settings.php CHANGED
@@ -1,8 +1,9 @@
1
  <?php
 
2
  $options = apply_filters('webpc_get_options', []);
3
  $values = apply_filters('webpc_get_values', []);
4
  ?>
5
- <form method="post" class="webpPage">
6
  <div class="webpPage__inner">
7
  <h1 class="webpPage__headline"><?= __('WebP Converter for Media', 'webp-converter'); ?></h1>
8
  <ul class="webpPage__columns">
1
  <?php
2
+ $path = sprintf('%s&_wpnonce=%s', menu_page_url('webpc_admin_page', false), wp_create_nonce('webpc-save'));
3
  $options = apply_filters('webpc_get_options', []);
4
  $values = apply_filters('webpc_get_values', []);
5
  ?>
6
+ <form method="post" action="<?= $path; ?>" class="webpPage">
7
  <div class="webpPage__inner">
8
  <h1 class="webpPage__headline"><?= __('WebP Converter for Media', 'webp-converter'); ?></h1>
9
  <ul class="webpPage__columns">
webp-converter-for-media.php CHANGED
@@ -3,13 +3,13 @@
3
  /*
4
  Plugin Name: WebP Converter for Media
5
  Description: Speed up your website by serving WebP images instead of standard formats JPEG, PNG and GIF.
6
- Version: 1.0.2
7
  Author: Mateusz Gbiorczyk
8
  Author URI: https://gbiorczyk.pl/
9
  Text Domain: webp-converter
10
  */
11
 
12
- define('WEBPC_VERSION', '1.0.2');
13
  define('WEBPC_FILE', __FILE__);
14
  define('WEBPC_NAME', plugin_basename(__FILE__));
15
  define('WEBPC_PATH', plugin_dir_path(__FILE__));
3
  /*
4
  Plugin Name: WebP Converter for Media
5
  Description: Speed up your website by serving WebP images instead of standard formats JPEG, PNG and GIF.
6
+ Version: 1.0.3
7
  Author: Mateusz Gbiorczyk
8
  Author URI: https://gbiorczyk.pl/
9
  Text Domain: webp-converter
10
  */
11
 
12
+ define('WEBPC_VERSION', '1.0.3');
13
  define('WEBPC_FILE', __FILE__);
14
  define('WEBPC_NAME', plugin_basename(__FILE__));
15
  define('WEBPC_PATH', plugin_dir_path(__FILE__));