66 *
77 * This content is released under the MIT License (MIT)
88 *
9- * Copyright (c) 2014 - 2015 , British Columbia Institute of Technology
9+ * Copyright (c) 2014 - 2016 , British Columbia Institute of Technology
1010 *
1111 * Permission is hereby granted, free of charge, to any person obtaining a copy
1212 * of this software and associated documentation files (the "Software"), to deal
2828 *
2929 * @package CodeIgniter
3030 * @author EllisLab Dev Team
31- * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http ://ellislab.com/)
32- * @copyright Copyright (c) 2014 - 2015 , British Columbia Institute of Technology (http://bcit.ca/)
31+ * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https ://ellislab.com/)
32+ * @copyright Copyright (c) 2014 - 2016 , British Columbia Institute of Technology (http://bcit.ca/)
3333 * @license http://opensource.org/licenses/MIT MIT License
34- * @link http ://codeigniter.com
34+ * @link https ://codeigniter.com
3535 * @since Version 1.0.0
3636 * @filesource
3737 */
4646 * @subpackage CodeIgniter
4747 * @category Common Functions
4848 * @author EllisLab Dev Team
49- * @link http ://codeigniter.com/user_guide/
49+ * @link https ://codeigniter.com/user_guide/
5050 */
5151
5252// ------------------------------------------------------------------------
@@ -181,7 +181,7 @@ function &load_class($class, $directory = 'libraries', $param = NULL)
181181 // Did we find the class?
182182 if ($ name === FALSE )
183183 {
184- // Note: We use exit() rather then show_error() in order to avoid a
184+ // Note: We use exit() rather than show_error() in order to avoid a
185185 // self-referencing loop with the Exceptions class
186186 set_status_header (503 );
187187 echo 'Unable to locate the specified class: ' .$ class .'.php ' ;
@@ -355,7 +355,7 @@ function is_https()
355355 {
356356 return TRUE ;
357357 }
358- elseif (isset ($ _SERVER ['HTTP_X_FORWARDED_PROTO ' ]) && $ _SERVER ['HTTP_X_FORWARDED_PROTO ' ] === 'https ' )
358+ elseif (isset ($ _SERVER ['HTTP_X_FORWARDED_PROTO ' ]) && strtolower ( $ _SERVER ['HTTP_X_FORWARDED_PROTO ' ]) === 'https ' )
359359 {
360360 return TRUE ;
361361 }
@@ -506,6 +506,9 @@ function set_status_header($code = 200, $text = '')
506506 {
507507 is_int ($ code ) OR $ code = (int ) $ code ;
508508 $ stati = array (
509+ 100 => 'Continue ' ,
510+ 101 => 'Switching Protocols ' ,
511+
509512 200 => 'OK ' ,
510513 201 => 'Created ' ,
511514 202 => 'Accepted ' ,
@@ -524,6 +527,7 @@ function set_status_header($code = 200, $text = '')
524527
525528 400 => 'Bad Request ' ,
526529 401 => 'Unauthorized ' ,
530+ 402 => 'Payment Required ' ,
527531 403 => 'Forbidden ' ,
528532 404 => 'Not Found ' ,
529533 405 => 'Method Not Allowed ' ,
@@ -540,13 +544,18 @@ function set_status_header($code = 200, $text = '')
540544 416 => 'Requested Range Not Satisfiable ' ,
541545 417 => 'Expectation Failed ' ,
542546 422 => 'Unprocessable Entity ' ,
547+ 426 => 'Upgrade Required ' ,
548+ 428 => 'Precondition Required ' ,
549+ 429 => 'Too Many Requests ' ,
550+ 431 => 'Request Header Fields Too Large ' ,
543551
544552 500 => 'Internal Server Error ' ,
545553 501 => 'Not Implemented ' ,
546554 502 => 'Bad Gateway ' ,
547555 503 => 'Service Unavailable ' ,
548556 504 => 'Gateway Timeout ' ,
549- 505 => 'HTTP Version Not Supported '
557+ 505 => 'HTTP Version Not Supported ' ,
558+ 511 => 'Network Authentication Required ' ,
550559 );
551560
552561 if (isset ($ stati [$ code ]))
@@ -594,7 +603,7 @@ function set_status_header($code = 200, $text = '')
594603 */
595604 function _error_handler ($ severity , $ message , $ filepath , $ line )
596605 {
597- $ is_error = (((E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR ) & $ severity ) === $ severity );
606+ $ is_error = (((E_ERROR | E_PARSE | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR ) & $ severity ) === $ severity );
598607
599608 // When an error occurred, set the status header to '500 Internal Server Error'
600609 // to indicate to the client something went wrong.
@@ -652,6 +661,7 @@ function _exception_handler($exception)
652661 $ _error =& load_class ('Exceptions ' , 'core ' );
653662 $ _error ->log_exception ('error ' , 'Exception: ' .$ exception ->getMessage (), $ exception ->getFile (), $ exception ->getLine ());
654663
664+ is_cli () OR set_status_header (500 );
655665 // Should we display the error?
656666 if (str_ireplace (array ('off ' , 'none ' , 'no ' , 'false ' , 'null ' ), '' , ini_get ('display_errors ' )))
657667 {
@@ -673,7 +683,7 @@ function _exception_handler($exception)
673683 * of CodeIgniter.php. The main reason we use this is to simulate
674684 * a complete custom exception handler.
675685 *
676- * E_STRICT is purposivly neglected because such events may have
686+ * E_STRICT is purposively neglected because such events may have
677687 * been caught. Duplication or none? None is preferred for now.
678688 *
679689 * @link http://insomanic.me.uk/post/229851073/php-trick-catching-fatal-errors-e-error-with-a
@@ -712,8 +722,8 @@ function remove_invisible_characters($str, $url_encoded = TRUE)
712722 // carriage return (dec 13) and horizontal tab (dec 09)
713723 if ($ url_encoded )
714724 {
715- $ non_displayables [] = '/%0[0-8bcef]/ ' ; // url encoded 00-08, 11, 12, 14, 15
716- $ non_displayables [] = '/%1[0-9a-f]/ ' ; // url encoded 16-31
725+ $ non_displayables [] = '/%0[0-8bcef]/i ' ; // url encoded 00-08, 11, 12, 14, 15
726+ $ non_displayables [] = '/%1[0-9a-f]/i ' ; // url encoded 16-31
717727 }
718728
719729 $ non_displayables [] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S ' ; // 00-08, 11, 12, 14-31, 127
@@ -745,10 +755,15 @@ function html_escape($var, $double_encode = TRUE)
745755 {
746756 return $ var ;
747757 }
748-
758+
749759 if (is_array ($ var ))
750760 {
751- return array_map ('html_escape ' , $ var , array_fill (0 , count ($ var ), $ double_encode ));
761+ foreach (array_keys ($ var ) as $ key )
762+ {
763+ $ var [$ key ] = html_escape ($ var [$ key ], $ double_encode );
764+ }
765+
766+ return $ var ;
752767 }
753768
754769 return htmlspecialchars ($ var , ENT_QUOTES , config_item ('charset ' ), $ double_encode );
@@ -829,19 +844,9 @@ function function_usable($function_name)
829844 {
830845 if ( ! isset ($ _suhosin_func_blacklist ))
831846 {
832- if (extension_loaded ('suhosin ' ))
833- {
834- $ _suhosin_func_blacklist = explode (', ' , trim (ini_get ('suhosin.executor.func.blacklist ' )));
835-
836- if ( ! in_array ('eval ' , $ _suhosin_func_blacklist , TRUE ) && ini_get ('suhosin.executor.disable_eval ' ))
837- {
838- $ _suhosin_func_blacklist [] = 'eval ' ;
839- }
840- }
841- else
842- {
843- $ _suhosin_func_blacklist = array ();
844- }
847+ $ _suhosin_func_blacklist = extension_loaded ('suhosin ' )
848+ ? explode (', ' , trim (ini_get ('suhosin.executor.func.blacklist ' )))
849+ : array ();
845850 }
846851
847852 return ! in_array ($ function_name , $ _suhosin_func_blacklist , TRUE );
0 commit comments