From 96ea8cd0db4066fbb8b0a8991152278d403074da Mon Sep 17 00:00:00 2001 From: "xiaoqi.cxq" Date: Wed, 18 Oct 2023 09:09:27 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E5=85=8Dundefined=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 5 ++++- server/pandoc.js | 2 +- src/services/providers/helpers/giteaHelper.js | 6 ++++++ src/services/providers/helpers/giteeHelper.js | 6 ++++++ src/services/providers/helpers/githubHelper.js | 6 ++++++ src/services/providers/helpers/gitlabHelper.js | 6 ++++++ static/landing/share.html | 1 + 7 files changed, 30 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index b769669b..df87c635 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,4 +3,7 @@ node_modules dist .history images -docs \ No newline at end of file +docs +Dockerfile +README.md +build.sh diff --git a/server/pandoc.js b/server/pandoc.js index f5fca770..cf93ac51 100644 --- a/server/pandoc.js +++ b/server/pandoc.js @@ -59,7 +59,7 @@ exports.generate = (req, res) => { const metadata = readJson(req.query.metadata); const params = []; - params.push('--latex-engine=xelatex'); + params.push('--pdf-engine=xelatex'); params.push('--webtex=http://chart.apis.google.com/chart?cht=tx&chf=bg,s,FFFFFF00&chco=000000&chl='); if (options.toc) { params.push('--toc'); diff --git a/src/services/providers/helpers/giteaHelper.js b/src/services/providers/helpers/giteaHelper.js index d9def936..c6188b28 100644 --- a/src/services/providers/helpers/giteaHelper.js +++ b/src/services/providers/helpers/giteaHelper.js @@ -317,6 +317,12 @@ export default { isImg, commitMessage, }) { + // 非法的文件名 不让提交 + if (!path || path.endsWith('undefined')) { + return new Promise((resolve) => { + resolve({ res: { content: { sha: null } } }); + }); + } let uploadContent = content; if (isImg && typeof content !== 'string') { uploadContent = await utils.encodeFiletoBase64(content); diff --git a/src/services/providers/helpers/giteeHelper.js b/src/services/providers/helpers/giteeHelper.js index f46f0c37..d734ba92 100644 --- a/src/services/providers/helpers/giteeHelper.js +++ b/src/services/providers/helpers/giteeHelper.js @@ -279,6 +279,12 @@ export default { isImg, commitMessage, }) { + // 非法的文件名 不让提交 + if (!path || path.endsWith('undefined')) { + return new Promise((resolve) => { + resolve({ res: { content: { sha: null } } }); + }); + } let uploadContent = content; if (isImg && typeof content !== 'string') { uploadContent = await utils.encodeFiletoBase64(content); diff --git a/src/services/providers/helpers/githubHelper.js b/src/services/providers/helpers/githubHelper.js index 777bbce3..9ea29e05 100644 --- a/src/services/providers/helpers/githubHelper.js +++ b/src/services/providers/helpers/githubHelper.js @@ -179,6 +179,12 @@ export default { isImg, commitMessage, }) { + // 非法的文件名 不让提交 + if (!path || path.endsWith('undefined')) { + return new Promise((resolve) => { + resolve({ res: { content: { sha: null } } }); + }); + } let uploadContent = content; if (isImg && typeof content !== 'string') { uploadContent = await utils.encodeFiletoBase64(content); diff --git a/src/services/providers/helpers/gitlabHelper.js b/src/services/providers/helpers/gitlabHelper.js index 542b89e2..c8725d35 100644 --- a/src/services/providers/helpers/gitlabHelper.js +++ b/src/services/providers/helpers/gitlabHelper.js @@ -281,6 +281,12 @@ export default { isImg, commitMessage, }) { + // 非法的文件名 不让提交 + if (!path || path.endsWith('undefined')) { + return new Promise((resolve) => { + resolve({ res: { content: { sha: null } } }); + }); + } let uploadContent = content; if (isImg && typeof content !== 'string') { uploadContent = await utils.encodeFiletoBase64(content); diff --git a/static/landing/share.html b/static/landing/share.html index ad8a22d2..9c4deb13 100644 --- a/static/landing/share.html +++ b/static/landing/share.html @@ -131,6 +131,7 @@ if (withToken) { withToken = false; xhr.open('GET', url); + xhr.send(); } else { console.error('An error occurred: ' + xhr.status); document.getElementById('div_info').innerHTML = `分享内容获取失败或已失效!请登录 主文档空间 后再刷新此页面!`;