Determines whether an extension is valid for a specific mime typ

@param string $sExt  The extension to test, no leading period
@param string $sMime The mime type to test against

@return bool
546426
public function validExtForMime($sExt, $sMime)
    {
        $sExt = $this->sanitiseExtension($sExt);
        return in_array($sExt, $this->oMimeService->getExtensionsForMime($sMime));
    }
381571
public function isTextPresent($sText)
    {
        $sHTML = $this->getMinkSession()->getPage()->getText();
        return (stripos($sHTML, $sText) !== false);
    }
611664
function isPlainText($s) {
        $arrfailAt = array("*", "fonttbl", "colortbl", "datastore", "themedata");
        for ($i = 0; $i < count($arrfailAt); $i++) {
            if (!empty($s[$arrfailAt[$i]])) {
                return false;
            }
        }
        return true;
    }
79255
protected static function isValidFragment(?string $fragment): bool
    {
        if ($fragment === null || $fragment === '') {
            return true;
        }

        // http://tools.ietf.org/html/rfc3986#section-3.5
        // fragment = *( pchar / "/" / "?" )
        // pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
        $pattern = sprintf(
            '/\A(?:[%s%s\/?:@]|(?:%s))*\z/',
            static::UNRESERVED_SET,
            static::SUB_DELIMS_SET,
            static::PCT_ENCODED_SET
        );

        return !!preg_match($pattern, $fragment);
    }
864700
public function checkMemoryLimit($sMemLimit = null)
    {
        if ($sMemLimit === null) {
            $sMemLimit = @ini_get('memory_limit');
        }

        if ($sMemLimit) {
            $sDefLimit = $this->_getMinimumMemoryLimit();
            $sRecLimit = $this->_getRecommendMemoryLimit();

            $iMemLimit = $this->_getBytes($sMemLimit);

            if ($iMemLimit === '-1') {
                // -1 is equivalent to no memory limit
                $iModStat = 2;
            } else {
                $iModStat = ($iMemLimit >= $this->_getBytes($sDefLimit)) ? 1 : 0;
                $iModStat = $iModStat ? (($iMemLimit >= $this->_getBytes($sRecLimit)) ? 2 : $iModStat) : $iModStat;
            }
        } else {
            $iModStat = -1;
        }

        return $iModStat;
    }
487250
public function mimeFromExtension($ext)
    {
        $ext = strtolower($ext);
        if (array_key_exists($ext, self::$mime_types_and_extensions)) {
            return self::$mime_types_and_extensions[$ext];
        }

        return false;
    }
1282367
private static function isValidUriFragment(?string $fragment): bool
    {
        if ($fragment === null || $fragment === '') {
            return true;
        }

        // http://tools.ietf.org/html/rfc3986#section-3.5
        // fragment = *( pchar / "/" / "?" )
        // pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
        $pattern = sprintf(
            '/\A(?:[%s%s\/?:@]|(?:%s))*\z/i',
            'a-z0-9\-._~',
            '!$&\'()*+,;=',
            '%[a-f0-9]{2}'
        );

        return !!preg_match($pattern, $fragment);
    }
838089
private function checkExt($ext)
    {
        if (!empty($this->allowExts)) {
            return in_array(strtolower($ext), $this->allowExts, true);
        }
        return true;
    }
549408
protected function _isValidSmtpHost($smtpHost)
    {
        $isSmtp = false;
        if ($smtpHost) {
            $match = [];
            $smtpPort = isset($this->SMTP_PORT)
                ? $this->SMTP_PORT
                : $this->smtpPort;
            if (Str::getStr()->preg_match('@^(.*?)(:([0-9]+))?$@i', $smtpHost, $match)) {
                $smtpHost = $match[1];
                if (isset($match[3]) && (int) $match[3] !== 0) {
                    $smtpPort = (int) $match[3];
                }
            }
            if ($isSmtp = (bool) ($rHandle = @fsockopen($smtpHost, $smtpPort, $errNo, $errStr, 30))) {
                // closing connection ..
                fclose($rHandle);
            }
        }

        return $isSmtp;
    }
433091
private function isValidExtension($extension, $base)
	{
		$ext = explode('_', $extension);
		$dir = '';

		switch ($ext[0])
		{
			case 'com':
				$dir = $base . DS . 'components' . DS . $extension;
			break;
			case 'mod':
				$dir = $base . DS . 'modules' . DS . $extension;
			break;
			case 'plg':
				$dir = $base . DS . 'plugins' . DS . $ext[1] . DS . $ext[2];
			break;
			default:
				return false;
			break;
		}

		return (is_dir($dir)) ? true : false;
	}
10932
def _is_valid_extension(extension):
    
    if not cfg.CONF.valid_extensions:
        return True

    valid = False
    for cext in cfg.CONF.valid_extensions:
        if not cext.startswith('.'):
            cext = '.%s' % cext
        if extension == cext:
            valid = True
            break

    return valid
512151
public function isValidExtension($extension)
    {
        $valid_page_types = implode('|', Grav::instance()['config']->get('system.pages.types'));

        // Strip the file extension for valid page types
        if (preg_match('/(' . $valid_page_types . ')/', $extension)) {
            return true;
        }
        return false;
    }
630553
public function match($contentType)
    {
        $parts = explode(';', $contentType);
        $mime = array_shift($parts);

        return (bool)preg_match('#[/+]json$#', trim($mime));
    }
1274356
public static function mimeToExt($mime)
    {
        static $mime_map;
        if (empty($mime_map)) {
            $mime_map = include (__DIR__ . '/Mime.php');
        }
        return isset($mime_map[$mime]) ? $mime_map[$mime] : null;
    }
130172
function isInputMIMETypeSupported( $mimeData )
    {
        $mimeTypes = $this->supportedInputMIMETypes();
        $mimeName = $mimeData;
        if ( is_array( $mimeData ) )
            $mimeName = $mimeData['name'];
        foreach ( $mimeTypes as $mimeType )
        {
            if ( strpos( $mimeType, '*' ) !== false )
            {
                $matchString = eZImageHandler::wildcardToRegexp( $mimeType );
                if ( preg_match( "#^" . $matchString . "$#", $mimeName ) )
                {
                    return true;
                }
            }
            else if ( $mimeType == $mimeName )
            {
                return true;
            }
        }
        return false;
    }
1078799
public static function fileExtType($sExt)
    {
        $aExt2type = array(
            'audio'       => array('aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma'),
            'video'       => array('asf', 'avi', 'divx', 'dv', 'flv',  'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv'),
            'document'    => array('doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'rtf', 'wp', 'wpd'),
            'spreadsheet' => array('numbers', 'ods', 'xls', 'xlsx', 'xlsb', 'xlsm'),
            'interactive' => array('key', 'ppt', 'pptx', 'pptm', 'odp', 'swf'),
            'text'        => array('asc', 'csv', 'tsv', 'txt'),
            'archive'     => array('bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip'),
            'code'        => array('css', 'htm', 'html', 'php', 'js'),
        );

        foreach ($aExt2type as $type => $exts) {
            if (in_array($sExt, $exts)) {
                return $type;
            }
        }

        return false;
    }
1148475
public static function hasExtension($extension) {
		static::ensureDataLoaded();

		$extension = strtolower($extension);
		foreach (static::$mime_types as $extensions) {
			if (is_array($extensions)) {
				if (in_array($extension, $extensions, true)) {
					return true;
				}
			} else if ($extension === $extensions) {
				return true;
			}
		}

		return false;
	}