fix: Remove some call and references to deprecated OC_Util class

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/51838/head
Côme Chilliet 1 year ago committed by Côme Chilliet
parent b20f74a95b
commit b2100484c0
  1. 2
      apps/settings/templates/help.php
  2. 2
      core/Listener/BeforeTemplateRenderedListener.php
  3. 2
      core/js/tests/specs/coreSpec.js
  4. 2
      lib/base.php
  5. 2
      lib/private/Image.php
  6. 9
      lib/private/Share20/Manager.php
  7. 5
      lib/private/Template/functions.php
  8. 3
      lib/public/Share/IManager.php
  9. 12
      lib/public/Util.php
  10. 20
      tests/lib/UtilTest.php

@ -3,7 +3,7 @@
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
\OC_Util::addStyle('settings', 'help');
\OCP\Util::addStyle('settings', 'help');
?>
<?php if ($_['knowledgebaseEmbedded'] === true) : ?>
<div id="app-navigation" role="navigation" tabindex="0">

@ -37,7 +37,7 @@ class BeforeTemplateRenderedListener implements IEventListener {
Util::addScript('core', 'public');
}
\OC_Util::addStyle('server', null, true);
Util::addStyle('server', null, true);
if ($event instanceof BeforeLoginTemplateRenderedEvent) {
// todo: make login work without these

@ -359,7 +359,7 @@ describe('Core base tests', function() {
// to make sure they run.
var cit = window.isPhantom?xit:it;
// must provide the same results as \OC_Util::naturalSortCompare
// must provide the same results as \OCP\Util::naturalSortCompare
it('sorts alphabetically', function() {
var a = [
'def',

@ -704,7 +704,7 @@ class OC {
if (count($errors) > 0) {
if (!self::$CLI) {
http_response_code(503);
OC_Util::addStyle('guest');
Util::addStyle('guest');
try {
Server::get(ITemplateManager::class)->printGuestPage('', 'error', ['errors' => $errors]);
exit;

@ -56,7 +56,7 @@ class Image implements IImage {
$this->appConfig = $appConfig ?? Server::get(IAppConfig::class);
$this->config = $config ?? Server::get(IConfig::class);
if (\OC_Util::fileInfoLoaded()) {
if (class_exists(finfo::class)) {
$this->fileInfo = new finfo(FILEINFO_MIME_TYPE);
}
}

@ -1965,14 +1965,9 @@ class Manager implements IManager {
}
/**
* Copied from \OC_Util::isSharingDisabledForUser
*
* TODO: Deprecate function from OC_Util
*
* @param string $userId
* @return bool
* Check if sharing is disabled for the current user
*/
public function sharingDisabledForUser($userId) {
public function sharingDisabledForUser(string $userId): bool {
return $this->shareDisableChecker->sharingDisabledForUser($userId);
}

@ -131,10 +131,10 @@ function script($app, $file = null): void {
function style($app, $file = null): void {
if (is_array($file)) {
foreach ($file as $f) {
OC_Util::addStyle($app, $f);
Util::addStyle($app, $f);
}
} else {
OC_Util::addStyle($app, $file);
Util::addStyle($app, $file);
}
}
@ -143,6 +143,7 @@ function style($app, $file = null): void {
* @param string $app the appname
* @param string|string[] $file the filename,
* if an array is given it will add all styles
* @deprecated 32.0.0
*/
function vendor_style($app, $file = null): void {
if (is_array($file)) {

@ -485,11 +485,10 @@ interface IManager {
/**
* Check if sharing is disabled for the given user
*
* @param string $userId
* @return bool
* @since 9.0.0
*/
public function sharingDisabledForUser($userId);
public function sharingDisabledForUser(string $userId);
/**
* Check if outgoing server2server shares are allowed

@ -102,13 +102,15 @@ class Util {
}
/**
* add a css file
* @param string $application
* @param string $file
* Add a css file
*
* @param string $application application id
* @param ?string $file filename
* @param bool $prepend prepend the style to the beginning of the list
* @since 4.0.0
*/
public static function addStyle($application, $file = null): void {
\OC_Util::addStyle($application, $file);
public static function addStyle(string $application, ?string $file = null, bool $prepend = false): void {
\OC_Util::addStyle($application, $file, $prepend);
}
/**

@ -42,25 +42,25 @@ class UtilTest extends \Test\TestCase {
'And It Even May &lt;strong&gt;Nest&lt;/strong&gt;'
],
];
$result = OC_Util::sanitizeHTML($badArray);
$result = Util::sanitizeHTML($badArray);
$this->assertEquals($goodArray, $result);
$badString = '<img onload="alert(1)" />';
$result = OC_Util::sanitizeHTML($badString);
$result = Util::sanitizeHTML($badString);
$this->assertEquals('&lt;img onload=&quot;alert(1)&quot; /&gt;', $result);
$badString = "<script>alert('Hacked!');</script>";
$result = OC_Util::sanitizeHTML($badString);
$result = Util::sanitizeHTML($badString);
$this->assertEquals('&lt;script&gt;alert(&#039;Hacked!&#039;);&lt;/script&gt;', $result);
$goodString = 'This is a good string without HTML.';
$result = OC_Util::sanitizeHTML($goodString);
$result = Util::sanitizeHTML($goodString);
$this->assertEquals('This is a good string without HTML.', $result);
}
public function testEncodePath(): void {
$component = '/§#@test%&^ä/-child';
$result = OC_Util::encodePath($component);
$result = Util::encodePath($component);
$this->assertEquals('/%C2%A7%23%40test%25%26%5E%C3%A4/-child', $result);
}
@ -295,12 +295,12 @@ class UtilTest extends \Test\TestCase {
}
public function testAddStyle(): void {
\OC_Util::addStyle('core', 'myFancyCSSFile1');
\OC_Util::addStyle('myApp', 'myFancyCSSFile2');
\OC_Util::addStyle('core', 'myFancyCSSFile0', true);
\OC_Util::addStyle('core', 'myFancyCSSFile10', true);
Util::addStyle('core', 'myFancyCSSFile1');
Util::addStyle('myApp', 'myFancyCSSFile2');
Util::addStyle('core', 'myFancyCSSFile0', true);
Util::addStyle('core', 'myFancyCSSFile10', true);
// add duplicate
\OC_Util::addStyle('core', 'myFancyCSSFile1');
Util::addStyle('core', 'myFancyCSSFile1');
$this->assertEquals([], Util::getScripts());
$this->assertEquals([

Loading…
Cancel
Save