1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-02-02 15:09:23 -05:00

Merge pull request #71 from sgerwk/master

truncate data: uri passed to the external viewer
This commit is contained in:
rkd77 2020-09-27 19:34:15 +02:00 committed by GitHub
commit 3dd17876a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1035,6 +1035,8 @@ subst_file(unsigned char *prog, unsigned char *file, unsigned char *uri)
* data from stdin instead of a file. */
int input = 1;
char *replace, *original = "% ";
int truncate;
int tlen = 40;
if (!init_string(&name)) return NULL;
@ -1048,10 +1050,14 @@ subst_file(unsigned char *prog, unsigned char *file, unsigned char *uri)
if (*prog == '%') {
prog++;
truncate = 0;
if (*prog == 'f' || *prog == ' ' || *prog == '\0')
replace = file;
else if (*prog == 'u')
else if (*prog == 'u') {
replace = uri;
if (!memcmp(uri, "data:", sizeof("data:") - 1))
truncate = 1;
}
else if (*prog == '%')
replace = "%";
else {
@ -1073,7 +1079,15 @@ subst_file(unsigned char *prog, unsigned char *file, unsigned char *uri)
cygwin_conv_to_full_win32_path(replace, new_path);
add_to_string(&name, new_path);
#else
add_shell_quoted_to_string(&name, replace, strlen(replace));
if (! truncate || strlen(replace) <= tlen)
add_shell_quoted_to_string(&name,
replace, strlen(replace));
else {
add_shell_quoted_to_string(&name,
replace, tlen);
add_shell_quoted_to_string(&name,
"...", sizeof("...") - 1);
}
#endif
prog++;
}