/usr/share/phpmyadmin/libraries/classes
NameSizeModeActions
Charsets/-0755rm
Command/-0755rm
Config/-0755rm
Controllers/-0755rm
Database/-0755rm
Dbal/-0755rm
Display/-0755rm
Engines/-0755rm
Exceptions/-0755rm
Export/-0755rm
Gis/-0755rm
Html/-0755rm
Import/-0755rm
Navigation/-0755rm
Plugins/-0755rm
Properties/-0755rm
Providers/-0755rm
Query/-0755rm
Server/-0755rm
Setup/-0755rm
Table/-0755rm
Twig/-0755rm
Utils/-0755rm
Advisor.php125170644editdlrm
Bookmark.php109440644editdlrm
BrowseForeigners.php110830644editdlrm
Charsets.php72670644editdlrm
CheckUserPrivileges.php122300644editdlrm
Config.php464560644editdlrm
Console.php34600644editdlrm
Core.php433440644editdlrm
CreateAddField.php179930644editdlrm
DatabaseInterface.php768020644editdlrm
DbTableExists.php32870644editdlrm
Encoding.php87150644editdlrm
Error.php143040644editdlrm
ErrorHandler.php175570644editdlrm
ErrorReport.php93640644editdlrm
Export.php473510644editdlrm
File.php217860644editdlrm
FileListing.php29230644editdlrm
Font.php57180644editdlrm
Footer.php107940644editdlrm
Git.php183810644editdlrm
Header.php219670644editdlrm
Import.php588400644editdlrm
Index.php154280644editdlrm
IndexColumn.php43310644editdlrm
InsertEdit.php1333090644editdlrm
InternalRelations.php177300644editdlrm
IpAllowDeny.php99970644editdlrm
Language.php45680644editdlrm
LanguageManager.php245320644editdlrm
Linter.php53740644editdlrm
ListAbstract.php18140644editdlrm
ListDatabase.php44020644editdlrm
Logging.php27810644editdlrm
Menu.php218120644editdlrm
Message.php195470644editdlrm
Mime.php9160644editdlrm
Normalization.php424750644editdlrm
OpenDocument.php86170644editdlrm
Operations.php387480644editdlrm
OutputBuffering.php40740644editdlrm
ParseAnalyze.php24290644editdlrm
Partition.php73400644editdlrm
Pdf.php44490644editdlrm
Plugins.php257830644editdlrm
Profiling.php23170644editdlrm
RecentFavoriteTable.php122970644editdlrm
Relation.php792470644editdlrm
RelationCleanup.php150510644editdlrm
Replication.php48430644editdlrm
ReplicationGui.php220380644editdlrm
ReplicationInfo.php49430644editdlrm
Response.php168640644editdlrm
Routing.php58450644editdlrm
Sanitize.php124180644editdlrm
SavedSearches.php122210644editdlrm
Scripts.php37260644editdlrm
Session.php81980644editdlrm
Sql.php682720644editdlrm
SqlQueryForm.php72860644editdlrm
StorageEngine.php128280644editdlrm
SubPartition.php33980644editdlrm
SystemDatabase.php37480644editdlrm
Table.php979610644editdlrm
TablePartitionDefinition.php66640644editdlrm
Template.php39620644editdlrm
Theme.php89690644editdlrm
ThemeManager.php98150644editdlrm
Tracker.php304970644editdlrm
Tracking.php381410644editdlrm
Transformations.php166850644editdlrm
TwoFactor.php69680644editdlrm
Types.php258050644editdlrm
Url.php89730644editdlrm
UserPassword.php72840644editdlrm
UserPreferences.php86570644editdlrm
Util.php1047680644editdlrm
Version.php5330644editdlrm
VersionInformation.php73190644editdlrm
ZipExtension.php110170644editdlrm
Edit: /usr/share/phpmyadmin/libraries/classes/Sanitize.php (12418B)
$value) { if (substr($value, 0, 2) !== './') { continue; } $valid_starts[$key] = '.' . $value; } } if ($other) { $valid_starts[] = 'mailto:'; $valid_starts[] = 'ftp://'; } if ($http) { $valid_starts[] = 'http://'; } if ($is_setup) { $valid_starts[] = '?page=form&'; $valid_starts[] = '?page=servers&'; } foreach ($valid_starts as $val) { if (substr($url, 0, strlen($val)) == $val) { return true; } } return false; } /** * Check if we are currently on a setup folder page */ public static function isSetup(): bool { return $GLOBALS['PMA_Config'] !== null && $GLOBALS['PMA_Config']->get('is_setup'); } /** * Callback function for replacing [a@link@target] links in bb code. * * @param array $found Array of preg matches * * @return string Replaced string */ public static function replaceBBLink(array $found) { /* Check for valid link */ if (! self::checkLink($found[1])) { return $found[0]; } /* a-z and _ allowed in target */ if (! empty($found[3]) && preg_match('/[^a-z_]+/i', $found[3])) { return $found[0]; } /* Construct target */ $target = ''; if (! empty($found[3])) { $target = ' target="' . $found[3] . '"'; if ($found[3] === '_blank') { $target .= ' rel="noopener noreferrer"'; } } /* Construct url */ if (substr($found[1], 0, 4) === 'http') { $url = Core::linkURL($found[1]); } else { $url = $found[1]; } return ''; } /** * Callback function for replacing [doc@anchor] links in bb code. * * @param array $found Array of preg matches * * @return string Replaced string */ public static function replaceDocLink(array $found) { if (count($found) >= 4) { /* doc@page@anchor pattern */ $page = $found[1]; $anchor = $found[3]; } else { /* doc@anchor pattern */ $anchor = $found[1]; if (strncmp('faq', $anchor, 3) == 0) { $page = 'faq'; } elseif (strncmp('cfg', $anchor, 3) == 0) { $page = 'config'; } else { /* Guess */ $page = 'setup'; } } $link = MySQLDocumentation::getDocumentationLink($page, $anchor, self::isSetup() ? '../' : './'); return ''; } /** * Sanitizes $message, taking into account our special codes * for formatting. * * If you want to include result in element attribute, you should escape it. * * Examples: * *

* *
bar * * @param string $message the message * @param bool $escape whether to escape html in result * @param bool $safe whether string is safe (can keep < and > chars) */ public static function sanitizeMessage(string $message, $escape = false, $safe = false): string { if (! $safe) { $message = strtr($message, ['<' => '<', '>' => '>']); } /* Interpret bb code */ $replace_pairs = [ '[em]' => '', '[/em]' => '', '[strong]' => '', '[/strong]' => '', '[code]' => '', '[/code]' => '', '[kbd]' => '', '[/kbd]' => '', '[br]' => '
', '[/a]' => '', '[/doc]' => '', '[sup]' => '', '[/sup]' => '', // used in common.inc.php: '[conferr]' => '', // used in libraries/Util.php '[dochelpicon]' => Html\Generator::getImage('b_help', __('Documentation')), ]; $message = strtr($message, $replace_pairs); /* Match links in bb code ([a@url@target], where @target is options) */ $pattern = '/\[a@([^]"@]*)(@([^]"]*))?\]/'; /* Find and replace all links */ $message = (string) preg_replace_callback($pattern, static function (array $match) { return self::replaceBBLink($match); }, $message); /* Replace documentation links */ $message = (string) preg_replace_callback( '/\[doc@([a-zA-Z0-9_-]+)(@([a-zA-Z0-9_-]*))?\]/', static function (array $match) { return self::replaceDocLink($match); }, $message ); /* Possibly escape result */ if ($escape) { $message = htmlspecialchars($message); } return $message; } /** * Sanitize a filename by removing anything besides legit characters * * Intended usecase: * When using a filename in a Content-Disposition header * the value should not contain ; or " * * When exporting, avoiding generation of an unexpected double-extension file * * @param string $filename The filename * @param bool $replaceDots Whether to also replace dots * * @return string the sanitized filename */ public static function sanitizeFilename($filename, $replaceDots = false) { $pattern = '/[^A-Za-z0-9_'; // if we don't have to replace dots if (! $replaceDots) { // then add the dot to the list of legit characters $pattern .= '.'; } $pattern .= '-]/'; $filename = preg_replace($pattern, '_', $filename); return $filename; } /** * Format a string so it can be a string inside JavaScript code inside an * eventhandler (onclick, onchange, on..., ). * This function is used to displays a javascript confirmation box for * "DROP/DELETE/ALTER" queries. * * @param string $a_string the string to format * @param bool $add_backquotes whether to add backquotes to the string or not * * @return string the formatted string * * @access public */ public static function jsFormat($a_string = '', $add_backquotes = true) { $a_string = htmlspecialchars((string) $a_string); $a_string = self::escapeJsString($a_string); // Needed for inline javascript to prevent some browsers // treating it as a anchor $a_string = str_replace('#', '\\#', $a_string); return $add_backquotes ? Util::backquote($a_string) : $a_string; } /** * escapes a string to be inserted as string a JavaScript block * enclosed by * this requires only to escape ' with \' and end of script block * * We also remove NUL byte as some browsers (namely MSIE) ignore it and * inserting it anywhere inside '', '\\' => '\\\\', '\'' => '\\\'', '"' => '\"', "\n" => '\n', "\r" => '\r', ] ) ); } /** * Formats a value for javascript code. * * @param string $value String to be formatted. * * @return int|string formatted value. */ public static function formatJsVal($value) { if (is_bool($value)) { if ($value) { return 'true'; } return 'false'; } if (is_int($value)) { return (int) $value; } return '"' . self::escapeJsString($value) . '"'; } /** * Formats an javascript assignment with proper escaping of a value * and support for assigning array of strings. * * @param string $key Name of value to set * @param mixed $value Value to set, can be either string or array of strings * @param bool $escape Whether to escape value or keep it as it is * (for inclusion of js code) * * @return string Javascript code. */ public static function getJsValue($key, $value, $escape = true) { $result = $key . ' = '; if (! $escape) { $result .= $value; } elseif (is_array($value)) { $result .= '['; foreach ($value as $val) { $result .= self::formatJsVal($val) . ','; } $result .= "];\n"; } else { $result .= self::formatJsVal($value) . ";\n"; } return $result; } /** * Removes all variables from request except allowed ones. * * @param string[] $allowList list of variables to allow * * @access public */ public static function removeRequestVars(&$allowList): void { // do not check only $_REQUEST because it could have been overwritten // and use type casting because the variables could have become // strings $keys = array_keys( array_merge((array) $_REQUEST, (array) $_GET, (array) $_POST, (array) $_COOKIE) ); foreach ($keys as $key) { if (! in_array($key, $allowList)) { unset($_REQUEST[$key], $_GET[$key], $_POST[$key]); continue; } // allowed stuff could be compromised so escape it // we require it to be a string if (isset($_REQUEST[$key]) && ! is_string($_REQUEST[$key])) { unset($_REQUEST[$key]); } if (isset($_POST[$key]) && ! is_string($_POST[$key])) { unset($_POST[$key]); } if (isset($_COOKIE[$key]) && ! is_string($_COOKIE[$key])) { unset($_COOKIE[$key]); } if (! isset($_GET[$key]) || is_string($_GET[$key])) { continue; } unset($_GET[$key]); } } }