<commit_before><?php
/**
* @version		$Id$
* @category		Koowa
* @package      Koowa_Filter
* @copyright    Copyright (C) 2007 - 2009 <NAME> and <NAME>. All rights reserved.
* @license      GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
* @link 		http://www.koowa.org
*/

/**
 * Internal url filter
 * 
 * Check if an refers to a legal URL inside the system. Use when 
 * redirecting to an URL that was passed in a request
 *
 * @todo		Do a proper implementation, see NookuFilterEditlink for ideas
 * 
 * @author		<NAME> <<EMAIL>>
 * @category	Koowa
 * @package     Koowa_Filter
 */
class KFilterInternalurl extends KFilterAbstract
{
	/**
	 * Validate a value
	 *
	 * @param	scalar	Value to be validated
	 * @return	bool	True when the variable is valid
	 */
	protected function _validate($value)
	{
		if(!is_string($value)) {
			return false;
		}
		
		if(stripos($value, print(KRequest::base())) === false) {
			return false;
		}
		
		return true;
	}
	
	/**
	 * Sanitize a value
	 *
	 * @param	scalar	Value to be sanitized
	 * @return	string
	 */
	protected function _sanitize($value)
	{
		//TODO : internal url's should not only have path and query information
		return filter_var($value, FILTER_SANITIZE_URL);
	}
}

<commit_msg>KRequest::base() return a KHttpUri object. Needs to be casted to string to make sure stripos is completed correctly.<commit_after><?php
/**
* @version		$Id$
* @category		Koowa
* @package      Koowa_Filter
* @copyright    Copyright (C) 2007 - 2009 <NAME> and <NAME>. All rights reserved.
* @license      GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
* @link 		http://www.koowa.org
*/

/**
 * Internal url filter
 * 
 * Check if an refers to a legal URL inside the system. Use when 
 * redirecting to an URL that was passed in a request
 *
 * @todo		Do a proper implementation, see NookuFilterEditlink for ideas
 * 
 * @author		<NAME> <<EMAIL>>
 * @category	Koowa
 * @package     Koowa_Filter
 */
class KFilterInternalurl extends KFilterAbstract
{
	/**
	 * Validate a value
	 *
	 * @param	scalar	Value to be validated
	 * @return	bool	True when the variable is valid
	 */
	protected function _validate($value)
	{
		if(!is_string($value)) {
			return false;
		}
			
		if(stripos($value, (string) KRequest::base()) === false) {
			return false;
		}
		
		return true;
	}
	
	/**
	 * Sanitize a value
	 *
	 * @param	scalar	Value to be sanitized
	 * @return	string
	 */
	protected function _sanitize($value)
	{
		//TODO : internal url's should not only have path and query information
		return filter_var($value, FILTER_SANITIZE_URL);
	}
}


{'fraction_non_alphanumeric': 0.1176923076923077, 'fraction_numerical': 0.008461538461538461, 'mean_word_length': 3.2224025974025974, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5388371', 'n_tokens_mistral': 940, 'n_tokens_neox': 848, 'n_words': 274}