mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
meaningful default save name for data: uri content
This commit is contained in:
parent
3dd17876a1
commit
90a141be2b
@ -611,6 +611,14 @@ add_uri_to_string(struct string *string, const struct uri *uri,
|
|||||||
|
|
||||||
if (!uri->datalen) return string;
|
if (!uri->datalen) return string;
|
||||||
|
|
||||||
|
if (uri->protocol == PROTOCOL_DATA) {
|
||||||
|
char *e;
|
||||||
|
add_bytes_to_string(string,
|
||||||
|
"data", sizeof("data") - 1);
|
||||||
|
e = get_extension_from_uri((struct uri *) uri);
|
||||||
|
return add_bytes_to_string(string, e, strlen(e));
|
||||||
|
}
|
||||||
|
|
||||||
for (pos = filename; *pos && !end_of_dir(*pos); pos++)
|
for (pos = filename; *pos && !end_of_dir(*pos); pos++)
|
||||||
if (wants(URI_FILENAME) && is_uri_dir_sep(uri, *pos))
|
if (wants(URI_FILENAME) && is_uri_dir_sep(uri, *pos))
|
||||||
filename = pos + 1;
|
filename = pos + 1;
|
||||||
@ -1316,6 +1324,10 @@ get_translated_uri(unsigned char *uristring, unsigned char *cwd)
|
|||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ADD_EXTENSION_FROM_TYPE(string, type, ext) \
|
||||||
|
if (!memcmp(uri->data, type ";", sizeof(type ";") - 1) || \
|
||||||
|
!memcmp(uri->data, type ",", sizeof(type ",") - 1)) \
|
||||||
|
return strdup("." ext);
|
||||||
|
|
||||||
unsigned char *
|
unsigned char *
|
||||||
get_extension_from_uri(struct uri *uri)
|
get_extension_from_uri(struct uri *uri)
|
||||||
@ -1326,6 +1338,15 @@ get_extension_from_uri(struct uri *uri)
|
|||||||
|
|
||||||
assert(pos);
|
assert(pos);
|
||||||
|
|
||||||
|
if (uri->protocol == PROTOCOL_DATA) {
|
||||||
|
ADD_EXTENSION_FROM_TYPE(uri->data, "image/gif", "gif")
|
||||||
|
ADD_EXTENSION_FROM_TYPE(uri->data, "image/jpeg", "jpg")
|
||||||
|
ADD_EXTENSION_FROM_TYPE(uri->data, "image/png", "png")
|
||||||
|
ADD_EXTENSION_FROM_TYPE(uri->data, "text/plain", "txt")
|
||||||
|
ADD_EXTENSION_FROM_TYPE(uri->data, "text/html", "html")
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
for (; *pos && !end_of_dir(*pos); pos++) {
|
for (; *pos && !end_of_dir(*pos); pos++) {
|
||||||
if (!afterslash && !extension && *pos == '.') {
|
if (!afterslash && !extension && *pos == '.') {
|
||||||
extension = pos;
|
extension = pos;
|
||||||
|
Loading…
Reference in New Issue
Block a user