com web/bugs: The selection box will now show the current type of Bug: include/functions.php
| From: | Sara Golemon | Date: | Mon, 12 Dec 2016 17:01:24 +0000 |
| Subject: | com web/bugs: The selection box will now show the current type of Bug: include/functions.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-25423@lists.php.net to get a copy of this message | ||
Commit: 21f5fd3484d763be5a53a354d0253a1c8f7b2f2b
Author: Runster <github@rundev.de> Fri, 1 Jul 2016 23:04:11 +0200
Committer: Sara Golemon <pollita@php.net> Mon, 12 Dec 2016 09:01:24 -0800
Parents: 5c6ec7d00b326c87a30c5b444aa47b87386282b4
Branches: master
Link: http://git.php.net/?p=web/bugs.git;a=commitdiff;h=21f5fd3484d763be5a53a354d0253a1c8f7b2f2b
Log:
The selection box will now show the current type of Bug
Committer's note: I rewrote this from the original PR
at https://github.com/php/web-bugs/pull/23 for
three reasons:
1. The preceeding code usually case folded $current,
but may not depending on the value of $all and $current.
This was likely the source of the original issue being addressed.
By using strcasecmp(), the comparison no longer cares about case.
2. While $bug_types is *probably* safe to output unescaped,
it makes sense to be defensive and add some output protection.
3. Readability
-Sara
Changed paths:
M include/functions.php
Diff:
diff --git a/include/functions.php b/include/functions.php
index 78490cb..c7e0dc0 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -585,12 +585,12 @@ function show_type_options($current = 'Bug', $all = false)
echo ">All</option>\n";
} elseif (!$current) {
$current = 'bug';
- } else {
- $current = strtolower($current);
}
foreach ($bug_types as $k => $v) {
- echo '<option value="', $k, '"', (($current == strtolower($k)) ?
' selected="selected"' : ''), ">{$k}</option>\n";
+ $selected = strcasecmp($current, $k) ? '' : ' selected="selected"';
+ $k = htmlentities($k, ENT_QUOTES);
+ echo "<option value=\"$k\"$selected>$k</option>";
}
}