1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-10 11:21:29 +00:00

Revert "repair code bug"

This commit is contained in:
Daniel Pan
2022-01-18 22:04:04 +08:00
committed by GitHub
parent d553fecdbe
commit 54004118c6
3 changed files with 3 additions and 5 deletions

View File

@@ -26,7 +26,7 @@ const { siteRoot, serviceUrl, seafileCollabServer } = window.app.config;
const userInfo = window.app.userInfo; const userInfo = window.app.userInfo;
const userName = userInfo.username; const userName = userInfo.username;
let dirPath = Utils.getDirName(filePath); let dirPath = Utils.getDirName(filePath);
const IMAGE_SUFFIXES = ['png', 'PNG', 'jpg', 'JPG', 'jpeg', 'JPEG', 'gif', 'GIF']; const IMAGE_SUFFIXES = ['png', 'PNG', 'jpg', 'JPG', 'gif', 'GIF'];
function getImageFileNameWithTimestamp() { function getImageFileNameWithTimestamp() {
var d = Date.now(); var d = Date.now();

View File

@@ -55,8 +55,7 @@ class FileContent extends React.Component {
let index2 = imagePath.indexOf('?'); let index2 = imagePath.indexOf('?');
imagePath = imagePath.substring(index + 5, index2); imagePath = imagePath.substring(index + 5, index2);
// change image url // change image url
// the image path has been encoded when inserting the image innerNode.data.src = serviceURL + '/view-image-via-share-link/?token=' + sharedToken + '&path=' + Utils.encodePath(imagePath);
innerNode.data.src = serviceURL + '/view-image-via-share-link/?token=' + sharedToken + '&path=' + imagePath;
} }
return innerNode; return innerNode;
} }

View File

@@ -1972,9 +1972,8 @@ def view_media_file_via_share_link(request):
# Translation ( ')' # Translation ( ')'
image_file_name = image_file_name.replace('(', '\(') image_file_name = image_file_name.replace('(', '\(')
image_file_name = image_file_name.replace(')', '\)') image_file_name = image_file_name.replace(')', '\)')
encoded_image_file_name = urllib.parse.quote(image_file_name)
p = re.compile('(%s)/lib/(%s)/file(.*?)%s\?raw=1' % (serviceURL, repo_id, encoded_image_file_name)) p = re.compile('(%s)/lib/(%s)/file(.*?)%s\?raw=1' % (serviceURL, repo_id, image_file_name))
result = re.search(p, file_content) result = re.search(p, file_content)
if not result: if not result:
return render_error(request, 'Image does not exist') return render_error(request, 'Image does not exist')