nextcloud / richdocuments

📑 Collabora Online for Nextcloud
https://nextcloud.com/collaboraonline
350 stars 115 forks source link

Custom fonts issue #3717

Closed vladimirdulov closed 2 months ago

vladimirdulov commented 4 months ago

Collabora Online doesn't load custom fonts uploaded on Nextcloud using remote_font_config.

I've found out that /apps/richdocuments/settings/fonts.json contains escaped slashes in fonts urls and for some reason Collabora doesn't load them. If JSON_UNESCAPED_SLASHES added to json_encode() in JSONResponse::render() it starts to work properly.

Not sure if it's a beauty workaround but it works if a new class JSONFontResponse implemented like:

class JSONFontsResponse extends JSONResponse {
        public function render() {
                return json_encode($this->data, JSON_HEX_TAG | JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES);
        }
}

then SettingsController::getJsonFontList() gets amended in https://github.com/nextcloud/richdocuments/blob/main/lib/Controller/SettingsController.php#L309

--  $response = new JSONResponse($fontList);
++ $response = new JSONFontsResponse($fontList);
juliushaertl commented 4 months ago

Will need to check, maybe there was an upstream change in online that caused this? @pedropintosilva Do you have any insight there?

joshtrichards commented 3 months ago

What version(s)? You skipped our bug report template. :)

I don't see escaping in my test instance (which was a little surprising, honestly).

juliushaertl commented 2 months ago

Closing as there is no feedback.

@vladimirdulov Please don't hesitate to reopen once provided the additional insights