Skip to content

Commit a10741d

Browse files
committed
Escaping improved even more
1 parent 743e669 commit a10741d

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

Controllers/Admin/NetworkMenuController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ private function processError($paramName, $paramErrorMessage)
8181
// 'add_action('admin_notices', ...)' doesn't work here (maybe due to fact, that 'admin_notices' has to be registered not later than X point in code)
8282

8383
// Works
84-
$sanitizedErrorMessage = '<div id="message" class="error"><p>'.esc_br_html($sanitizedErrorMessage).'</p></div>';
84+
$errorMessageHTML = '<div id="message" class="error"><p>'.esc_br_html($sanitizedErrorMessage).'</p></div>';
8585

86-
// Based on WP Coding Standards ticket #341, the WordPress '_doing_it_wrong' method does not escapes the HTML by default,
87-
// so this has to be done by us. Read more: https://github.com/WordPress/WordPress-Coding-Standards/pull/341
88-
_doing_it_wrong(esc_html($sanitizedName), esc_br_html($sanitizedErrorMessage), $this->conf->getPluginSemver());
86+
// Based on WP Coding Standards ticket #340, the WordPress '_doing_it_wrong' method does not escapes the HTML by default,
87+
// so this has to be done by us. Read more: https://github.com/WordPress/WordPress-Coding-Standards/pull/340
88+
_doing_it_wrong(esc_html($sanitizedName), $errorMessageHTML, $this->conf->getPluginSemver());
8989
}
9090
}
9191
}

Controllers/Admin/SingleMenuController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,11 @@ private function processError($paramName, $paramErrorMessage)
257257
// 'add_action('admin_notices', ...)' doesn't work here (maybe due to fact, that 'admin_notices' has to be registered not later than X point in code)
258258

259259
// Works
260-
$sanitizedErrorMessage = '<div id="message" class="error"><p>'.esc_br_html($sanitizedErrorMessage).'</p></div>';
260+
$errorMessageHTML = '<div id="message" class="error"><p>'.esc_br_html($sanitizedErrorMessage).'</p></div>';
261261

262-
// Based on WP Coding Standards ticket #341, the WordPress '_doing_it_wrong' method does not escapes the HTML by default,
263-
// so this has to be done by us. Read more: https://github.com/WordPress/WordPress-Coding-Standards/pull/341
264-
_doing_it_wrong(esc_html($sanitizedName), esc_br_html($sanitizedErrorMessage), $this->conf->getPluginSemver());
262+
// Based on WP Coding Standards ticket #340, the WordPress '_doing_it_wrong' method does not escapes the HTML by default,
263+
// so this has to be done by us. Read more: https://github.com/WordPress/WordPress-Coding-Standards/pull/340
264+
_doing_it_wrong(esc_html($sanitizedName), $errorMessageHTML, $this->conf->getPluginSemver());
265265
}
266266
}
267267
}

Controllers/MainController.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,24 +1380,26 @@ private function processError($paramMethodName, $paramErrorMessage)
13801380
{
13811381
if(StaticValidator::inWP_Debug())
13821382
{
1383+
// Load errors only in local or global debug mode
1384+
13831385
// NOTE: add_action('admin_notices', ...); doesn't always work - maybe due to fact, that 'admin_notices'
13841386
// has to be registered not later than X point in code. So we use '_doing_it_wrong' instead
13851387
// Works
13861388
if(!is_null($this->confWithoutRouting))
13871389
{
1388-
$validErrorMessage = '<div class="'.$this->confWithoutRouting->getPluginCSS_Prefix().'error"><div id="message" class="error"><p>'.esc_html($paramMethodName).'</p></div></div>';
1390+
$errorMessageHTML = '<div class="'.$this->confWithoutRouting->getPluginCSS_Prefix().'error"><div id="message" class="error"><p>'.esc_html($paramMethodName).'</p></div></div>';
13891391

1390-
// Based on WP Coding Standards ticket #341, the WordPress '_doing_it_wrong' method does not escapes the HTML by default,
1391-
// so this has to be done by us. Read more: https://github.com/WordPress/WordPress-Coding-Standards/pull/341
1392-
_doing_it_wrong(esc_html($paramMethodName), esc_br_html($validErrorMessage), $this->confWithoutRouting->getPluginSemver());
1392+
// Based on WP Coding Standards ticket #340, the WordPress '_doing_it_wrong' method does not escapes the HTML by default,
1393+
// so this has to be done by us. Read more: https://github.com/WordPress/WordPress-Coding-Standards/pull/340
1394+
_doing_it_wrong(esc_html($paramMethodName), $errorMessageHTML, $this->confWithoutRouting->getPluginSemver());
13931395
} else
13941396
{
13951397
// $confWithoutRouting is NULL
1396-
$validErrorMessage = '<div id="message" class="error"><p>'.esc_br_html($paramErrorMessage).'</p></div>';
1398+
$errorMessageHTML = '<div id="message" class="error"><p>'.esc_br_html($paramErrorMessage).'</p></div>';
13971399

1398-
// Based on WP Coding Standards ticket #341, the WordPress '_doing_it_wrong' method does not escapes the HTML by default,
1399-
// so this has to be done by us. Read more: https://github.com/WordPress/WordPress-Coding-Standards/pull/341
1400-
_doing_it_wrong(esc_html($paramMethodName), esc_br_html($validErrorMessage), 0.0);
1400+
// Based on WP Coding Standards ticket #340, the WordPress '_doing_it_wrong' method does not escapes the HTML by default,
1401+
// so this has to be done by us. Read more: https://github.com/WordPress/WordPress-Coding-Standards/pull/340
1402+
_doing_it_wrong(esc_html($paramMethodName), $errorMessageHTML, 0.0);
14011403
}
14021404
}
14031405
}

0 commit comments

Comments
 (0)