<commit_before><?php
/**
 * Pintsize
 *
 * Basic user input checking
 */

class Input
{
    const pattern = '/[a-z0-9]{1,256}/i';
    /*  URL
     *  
     *  @return Sanitized URL
     */
    public static function url()
    {
        if (filter_var(trim($_REQUEST['url']), FILTER_VALIDATE_URL)) {
            return filter_var(trim($_REQUEST['url']), FILTER_SANITIZE_URL);
        }
    }

    /* Custom
     *
     * @return string   Custom URL value being requested
     */
    public static function custom()
    {
        if (preg_match(self::pattern, $_REQUEST['custom'])) {
            return $_REQUEST['custom'];
        }
    }

    /* Shortcode
     *
     * @return string   Return a shortcode if it's valid
     */
    public static function shortcode()
    {
        if (preg_match(self::pattern, $_REQUEST['shortcode'])) {
            return $_REQUEST['shortcode'];
        }
    }

}
?><commit_msg>checking for values before attempting to use them ;)<commit_after><?php
/**
 * Pintsize
 *
 * Basic user input checking
 */

class Input
{
    const pattern = '/[a-z0-9]{1,256}/i';
    /*  URL
     *  
     *  @return Sanitized URL
     */
    public static function url()
    {
        if (isset($_REQUEST['url']) && filter_var(trim($_REQUEST['url']), FILTER_VALIDATE_URL)) {
            return filter_var(trim($_REQUEST['url']), FILTER_SANITIZE_URL);
        }
    }

    /* Custom
     *
     * @return string   Custom URL value being requested
     */
    public static function custom()
    {
        if (isset($_REQUEST['custom']) && preg_match(self::pattern, $_REQUEST['custom'])) {
            return $_REQUEST['custom'];
        }
    }

    /* Shortcode
     *
     * @return string   Return a shortcode if it's valid
     */
    public static function shortcode()
    {
        if (isset($_REQUEST['shortcode']) && preg_match(self::pattern, $_REQUEST['shortcode'])) {
            return $_REQUEST['shortcode'];
        }
    }

}
?>
{'fraction_non_alphanumeric': 0.14665304036791008, 'fraction_numerical': 0.0061318344404701075, 'mean_word_length': 2.173419773095624, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1957825', 'n_tokens_mistral': 607, 'n_tokens_neox': 590, 'n_words': 131}