File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -168,10 +168,10 @@ function db_init_aux($try_replica=false) {
168168 if ($ x ) $ db_name = $ x ;
169169 }
170170 }
171- if (! $ host ) {
171+ if (is_blank ( $ host) ) {
172172 $ host = parse_config ($ config , "<db_host> " );
173173 }
174- if (! $ host ) {
174+ if (is_blank ( $ host) ) {
175175 $ host = "localhost " ;
176176 }
177177 if (1 ) {
Original file line number Diff line number Diff line change @@ -242,6 +242,13 @@ function time_diff($x, $res=3) {
242242 return $ s ;
243243}
244244
245+ // is the arg either null, '', or whitespace?
246+ // Note: if ($x) will be false if $x is '0'.
247+ // We don't want to treat '0' as blank.
248+ //
249+ function is_blank ($ x ) {
250+ return $ x === null || trim ($ x ) === '' ;
251+ }
245252
246253// security vulnerabilities and user-supplied strings:
247254// sources:
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ function db_init_cli() {
103103 $ config = get_config ();
104104 $ db_name = parse_config ($ config , "<db_name> " );
105105 $ host = parse_config ($ config , "<db_host> " );
106- if (! $ host ) {
106+ if (is_blank ( $ host) ) {
107107 $ host = "localhost " ;
108108 }
109109 $ in = fopen ("php://stdin " ,"r " );
Original file line number Diff line number Diff line change @@ -199,7 +199,7 @@ function do_send_team($logged_in_user) {
199199 error_page ("no team admin " );
200200 }
201201
202- if (! $ subject || ! $ content ) {
202+ if (is_blank ( $ subject) || is_blank ( $ content) ) {
203203 pm_team_form (
204204 $ logged_in_user , $ teamid ,
205205 tra ("You need to fill all fields to send a private message " )
@@ -235,7 +235,7 @@ function do_send($logged_in_user) {
235235 pm_form_page ($ replyto , $ userid );
236236 return ;
237237 }
238- if (! $ to || ! $ subject || ! $ content ) {
238+ if (is_blank ( $ to) || is_blank ( $ subject) || is_blank ( $ content) ) {
239239 pm_form_page (
240240 $ replyto , $ userid ,
241241 tra ("You need to fill all fields to send a private message " )
You can’t perform that action at this time.
0 commit comments