mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Merge pull request #73 from sgerwk/master
meaningful default save name for data: uri content
This commit is contained in:
commit
863c59a46c
@ -611,6 +611,15 @@ 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_to_string(string, "data");
|
||||||
|
e = get_extension_from_uri((struct uri *) uri);
|
||||||
|
add_to_string(string, e);
|
||||||
|
mem_free(e);
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
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 +1325,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 stracpy("." ext);
|
||||||
|
|
||||||
unsigned char *
|
unsigned char *
|
||||||
get_extension_from_uri(struct uri *uri)
|
get_extension_from_uri(struct uri *uri)
|
||||||
@ -1326,6 +1339,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 stracpy("");
|
||||||
|
}
|
||||||
|
|
||||||
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