mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
onlyoffice: handle invalid url error
This commit is contained in:
2 files changed
+18
-9
No files matched your search
@@ -23,13 +23,17 @@ const loader = (mode) => async (element) => {
|
|||||||
const id = `${mode}-${Math.random().toString()}`;
|
const id = `${mode}-${Math.random().toString()}`;
|
||||||
$(element).attr('id', id);
|
$(element).attr('id', id);
|
||||||
const url = new URL($(element).text(), window.location.href).toString();
|
const url = new URL($(element).text(), window.location.href).toString();
|
||||||
const payload = await request.get('/onlyoffice-jwt', { url });
|
try {
|
||||||
// @ts-ignore
|
const payload = await request.get('/onlyoffice-jwt', { url });
|
||||||
window.editor = new DocsAPI.DocEditor(id, {
|
// @ts-ignore
|
||||||
...payload,
|
window.editor = new DocsAPI.DocEditor(id, {
|
||||||
documentType: mode,
|
...payload,
|
||||||
height: mode === 'slide' ? '560px' : '900px',
|
documentType: mode,
|
||||||
});
|
height: mode === 'slide' ? '560px' : '900px',
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getEles = (types: string[]) => types.flatMap((type) => $(`div[data-${type}]`).get());
|
const getEles = (types: string[]) => types.flatMap((type) => $(`div[data-${type}]`).get());
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { sign } from 'jsonwebtoken';
|
import { sign } from 'jsonwebtoken';
|
||||||
import { } from '@hydrooj/ui-default/backendlib/markdown-it-media';
|
import { } from '@hydrooj/ui-default/backendlib/markdown-it-media';
|
||||||
import {
|
import {
|
||||||
Context, Handler, superagent, SystemModel, UiContextBase,
|
Context, Handler, superagent, SystemModel, UiContextBase, ValidationError,
|
||||||
} from 'hydrooj';
|
} from 'hydrooj';
|
||||||
|
|
||||||
declare module 'hydrooj' {
|
declare module 'hydrooj' {
|
||||||
@@ -19,7 +19,12 @@ class OnlyofficeJWTHandler extends Handler {
|
|||||||
const res = await superagent.get(SystemModel.get('onlyoffice.externalSign')).query({ url });
|
const res = await superagent.get(SystemModel.get('onlyoffice.externalSign')).query({ url });
|
||||||
this.response.body = res.body;
|
this.response.body = res.body;
|
||||||
}
|
}
|
||||||
const path = new URL(url).pathname;
|
let path: string;
|
||||||
|
try {
|
||||||
|
path = new URL(url).pathname;
|
||||||
|
} catch (e) {
|
||||||
|
throw new ValidationError('url');
|
||||||
|
}
|
||||||
const allowDownload = !!SystemModel.get('onlyoffice.allowDownload');
|
const allowDownload = !!SystemModel.get('onlyoffice.allowDownload');
|
||||||
const payload = {
|
const payload = {
|
||||||
document: {
|
document: {
|
||||||
|
|||||||
Reference in new issue
Block a user