mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-10 19:29:56 +00:00
repair share file image bug (#4543)
This commit is contained in:
@@ -55,7 +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
|
||||||
innerNode.data.src = serviceURL + '/view-image-via-share-link/?token=' + sharedToken + '&path=' + imagePath;
|
innerNode.data.src = serviceURL + '/view-image-via-share-link/?token=' + sharedToken + '&path=' + Utils.encodePath(imagePath);
|
||||||
}
|
}
|
||||||
return innerNode;
|
return innerNode;
|
||||||
}
|
}
|
||||||
|
@@ -1967,14 +1967,18 @@ def view_media_file_via_share_link(request):
|
|||||||
# If the image does not exist in markdown
|
# If the image does not exist in markdown
|
||||||
serviceURL = get_service_url().rstrip('/')
|
serviceURL = get_service_url().rstrip('/')
|
||||||
image_file_name = os.path.basename(image_path)
|
image_file_name = os.path.basename(image_path)
|
||||||
image_file_name = urlquote(image_file_name)
|
|
||||||
|
# Translation ‘(’ ')'
|
||||||
|
image_file_name = image_file_name.replace('(', '\(')
|
||||||
|
image_file_name = image_file_name.replace(')', '\)')
|
||||||
|
|
||||||
p = re.compile('(%s)/lib/(%s)/file(.*?)%s\?raw=1' % (serviceURL, repo_id, 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')
|
||||||
|
|
||||||
# get image
|
# get image
|
||||||
obj_id = seafile_api.get_file_id_by_path(repo_id, image_path)
|
obj_id = seafile_api.get_file_id_by_path(repo_id, urllib2.unquote(image_path))
|
||||||
if not obj_id:
|
if not obj_id:
|
||||||
return render_error(request, 'Image does not exist')
|
return render_error(request, 'Image does not exist')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user