$upload_max_filesize = OC::$server->getIniWrapper()->getBytes('upload_max_filesize');
$post_max_size = OC::$server->getIniWrapper()->getBytes('post_max_size');
$maxUploadFilesize = OCP\Util::humanFileSize(min($upload_max_filesize, $post_max_size));
-if($_POST && OC_Util::isCallRegistered()) {
+if($_POST && \OC::$server->getRequest()->passesCSRFCheck()) {
if(isset($_POST['maxUploadSize'])) {
if(($setMaxSize = OC_Files::setUploadLimit(OCP\Util::computerFileSize($_POST['maxUploadSize']))) !== false) {
$maxUploadFilesize = OCP\Util::humanFileSize($setMaxSize);
return false;
}
- if(!OC_Util::isCallRegistered()) {
+ if(!(\OC::$server->getRequest()->passesCSRFCheck())) {
return false;
}
OC_App::loadApps();
} else {
header("Content-Type: text/event-stream");
}
- if (!OC_Util::isCallRegistered()) {
+ if (!(\OC::$server->getRequest()->passesCSRFCheck())) {
$this->send('error', 'Possible CSRF attack. Connection will be closed.');
$this->close();
exit();
* @deprecated Use annotation based CSRF checks from the AppFramework instead
*/
public static function callCheck() {
- if( !OC_Util::isCallRegistered()) {
+ if( !(\OC::$server->getRequest()->passesCSRFCheck())) {
$l = \OC::$server->getL10N('lib');
self::error(array( 'data' => array( 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' )));
exit();
* Creates a 'request token' (random) and stores it inside the session.
* Ever subsequent (ajax) request must use such a valid token to succeed,
* otherwise the request will be denied as a protection against CSRF.
- * @see OC_Util::isCallRegistered()
*/
public static function callRegister() {
// Use existing token if function has already been called
return self::$obfuscatedToken;
}
- /**
- * Check an ajax get/post call if the request token is valid.
- *
- * @return boolean False if request token is not set or is invalid.
- * @see OC_Util::callRegister()
- */
- public static function isCallRegistered() {
- return \OC::$server->getRequest()->passesCSRFCheck();
- }
-
- /**
- * Check an ajax get/post call if the request token is valid. Exit if not.
- *
- * @return void
- */
- public static function callCheck() {
- if (!OC_Util::isCallRegistered()) {
- exit();
- }
- }
-
/**
* Public function to sanitize HTML
*
* @since 4.5.0
*/
public static function callCheck() {
- \OC_Util::callCheck();
+ if (!(\OC::$server->getRequest()->passesCSRFCheck())) {
+ exit();
+ }
}
/**