mirror of
https://github.com/vrana/adminer.git
synced 2025-08-16 11:34:10 +02:00
Remove definer from routine and event
This commit is contained in:
@@ -574,7 +574,7 @@ username.form['auth[driver]'].onchange();
|
||||
}
|
||||
if ($is_view) {
|
||||
// remove DEFINER with current user
|
||||
$create = preg_replace('~^([A-Z =]+) DEFINER=`' . preg_replace('~@(.*)~', '`@`(%|\\1)', logged_user()) . '`~', '\\1', $create); //! proper escaping of user
|
||||
$create = remove_definer($create);
|
||||
}
|
||||
echo ($style != "CREATE+ALTER" ? $create : ($is_view ? substr_replace($create, " OR REPLACE", 6, 0) : substr_replace($create, " IF NOT EXISTS", 12, 0))) . ";\n\n";
|
||||
}
|
||||
|
@@ -357,6 +357,14 @@ function drop_create($drop, $create, $location, $message_drop, $message_alter, $
|
||||
return $dropped;
|
||||
}
|
||||
|
||||
/** Remove current user definer from SQL command
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function remove_definer($query) {
|
||||
return preg_replace('~^([A-Z =]+) DEFINER=`' . preg_replace('~@(.*)~', '`@`(%|\\1)', logged_user()) . '`~', '\\1', $query); //! proper escaping of user
|
||||
}
|
||||
|
||||
/** Get string to add a file in TAR
|
||||
* @param string
|
||||
* @param string
|
||||
|
Reference in New Issue
Block a user