Skip to content

Commit

Permalink
[bug] Lowercase fileType param; Fix bug 65653
Browse files Browse the repository at this point in the history
  • Loading branch information
konovalovsergey committed Dec 22, 2023
1 parent c38b8aa commit a1e994a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions DocService/sources/DocsCoServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2236,8 +2236,7 @@ exports.install = function(server, callbackFunction) {
if (decoded.fileInfo) {
let fileInfo = decoded.fileInfo;
if (openCmd) {
let fileType = fileInfo.BaseFileName ? fileInfo.BaseFileName.substr(fileInfo.BaseFileName.lastIndexOf('.') + 1) : "";
openCmd.format = fileInfo.FileExtension ? fileInfo.FileExtension.substr(1) : fileType;
openCmd.format = wopiClient.getFileTypeByInfo(fileInfo);
openCmd.title = fileInfo.BreadcrumbDocName || fileInfo.BaseFileName;
}
let name = fileInfo.IsAnonymousUser ? "" : fileInfo.UserFriendlyName;
Expand Down
9 changes: 7 additions & 2 deletions DocService/sources/wopiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ function getWopiUnlockMarker(wopiParams) {
function getWopiModifiedMarker(wopiParams, lastModifiedTime) {
return JSON.stringify(Object.assign({fileInfo: {LastModifiedTime: lastModifiedTime}}, wopiParams.userAuth));
}
function getFileTypeByInfo(fileInfo) {
let fileType = fileInfo.BaseFileName ? fileInfo.BaseFileName.substr(fileInfo.BaseFileName.lastIndexOf('.') + 1) : "";
fileType = fileInfo.FileExtension ? fileInfo.FileExtension.substr(1) : fileType;
return fileType.toLowerCase();
}
function getLastModifiedTimeFromCallbacks(callbacks) {
for (let i = callbacks.length; i >= 0; --i) {
let callback = callbacks[i];
Expand Down Expand Up @@ -429,8 +434,7 @@ function getEditorHtml(req, res) {
}
//save common info
if (undefined === lockId) {
let fileType = fileInfo.BaseFileName ? fileInfo.BaseFileName.substr(fileInfo.BaseFileName.lastIndexOf('.') + 1) : "";
fileType = fileInfo.FileExtension ? fileInfo.FileExtension.substr(1) : fileType;
let fileType = getFileTypeByInfo(fileInfo);
lockId = crypto.randomBytes(16).toString('base64');
let commonInfo = JSON.stringify({lockId: lockId, fileInfo: fileInfo});
yield canvasService.commandOpenStartPromise(ctx, docId, utils.getBaseUrlByRequest(ctx, req), commonInfo, fileType);
Expand Down Expand Up @@ -841,3 +845,4 @@ exports.generateProofOld = generateProofOld;
exports.fillStandardHeaders = fillStandardHeaders;
exports.getWopiUnlockMarker = getWopiUnlockMarker;
exports.getWopiModifiedMarker = getWopiModifiedMarker;
exports.getFileTypeByInfo = getFileTypeByInfo;

0 comments on commit a1e994a

Please sign in to comment.