works except for upload progress

This commit is contained in:
or-else
2020-10-16 17:43:12 -07:00
parent 738d84045d
commit 796f16a003
10 changed files with 81 additions and 196 deletions
+7 -6
View File
@@ -93,8 +93,8 @@ export function isUrlRelative(url) {
// Ensure URL does not present an XSS risk. Optional allowedSchemes may contain an array of
// strings with permitted URL schemes, such as ['ftp', 'ftps']; otherwise accept http and https only.
// If apikey is defined, it's appended to relative URL.
export function sanitizeUrl(url, apikey) {
// If apikey and/or token is defined, it's appended to relative URL.
export function sanitizeUrl(url) {
if (!url) {
return null;
}
@@ -107,6 +107,7 @@ export function sanitizeUrl(url, apikey) {
if (!/^([a-z][a-z0-9+.-]*:|\/\/)/i.test(url)) {
return url;
}
// Blob URLs are safe.
if (/^blob:http/.test(url)) {
return url;
@@ -123,15 +124,15 @@ export function sanitizeUrl(url, apikey) {
}
// Ensure URL is suitable for <img src="url"> field: the URL must be a relative URL or
// have http:, https:, or data: scheme.
// The relative URL is appended with the API key.
// have http:, https:, blob: or data: scheme.
// The relative URL is appended with the API key and/or auth token.
// In case of data: scheme, the URL must start with a 'data:image/XXXX;base64,'.
export function sanitizeImageUrl(url, apikey) {
export function sanitizeImageUrl(url) {
if (!url) {
return null;
}
const sanitizedUrl = sanitizeUrl(url, apikey);
const sanitizedUrl = sanitizeUrl(url);
if (sanitizedUrl) {
return sanitizedUrl;
}