bug fix: do not alter data or blob URLs with [asatt]

This commit is contained in:
or-else
2024-02-10 11:33:36 -08:00
parent 7f2a89d86c
commit 354ce3b8a3
5 changed files with 12 additions and 4 deletions
+6 -1
View File
@@ -174,7 +174,7 @@ export function sanitizeUrlForMime(url, mimeMajor) {
// Append query parameter 'asatt=1' to the URL.
// It will cause Tinode server to add 'Content-Disposition: attachment' header when serving it.
// The URL here is always absolute.
// The URL is a string. The URL here is always absolute.
export function urlAsAttachment(url) {
// TODO: check if URL is local or remote, i.e. compare to window.location.origin.
/*
@@ -184,6 +184,11 @@ export function urlAsAttachment(url) {
}
}
*/
// Check if the URL is a data or blob. Do not alter such URLs.
if (url.startsWith('data:') || url.startsWith('blob:')) {
return url;
}
// Split URL into host+path, query, fragment.
let query = '', fragment = '';
const idxF = url.indexOf('#');
+3
View File
@@ -3545,6 +3545,9 @@ function sanitizeUrlForMime(url, mimeMajor) {
return null;
}
function urlAsAttachment(url) {
if (url.startsWith('data:') || url.startsWith('blob:')) {
return url;
}
let query = '',
fragment = '';
const idxF = url.indexOf('#');
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long