Fossil SCM
Added --as FILENAME option to the (chat send) command, which uses FILENAME as the attachment name for the file specified by the --file flag. Mimetype guessing for the attachment is based on the --as name.
Commit
2bb3c76ad9e78e44f02b9d8d67914cd258800ec2f0bf7c422edf714c97043caa
Parent
3e74ae503f2113a…
1 file changed
+5
-2
+5
-2
| --- src/chat.c | ||
| +++ src/chat.c | ||
| @@ -834,10 +834,12 @@ | ||
| 834 | 834 | ** |
| 835 | 835 | ** This command sends a new message to the chatroom. The message |
| 836 | 836 | ** to be sent is determined by arguments as follows: |
| 837 | 837 | ** |
| 838 | 838 | ** -f|--file FILENAME File to attach to the message |
| 839 | +** --as FILENAME2 Causes --file FILENAME to be sent with | |
| 840 | +** the attachment name FILENAME2 | |
| 839 | 841 | ** -m|--message TEXT Text of the chat message |
| 840 | 842 | ** --remote URL Send to this remote URL |
| 841 | 843 | ** --unsafe Allow the use of unencrypted http:// |
| 842 | 844 | ** |
| 843 | 845 | ** > fossil chat url |
| @@ -891,10 +893,11 @@ | ||
| 891 | 893 | zCmd = mprintf("%s \"%s/chat?cli\" &", zBrowser, zUrl); |
| 892 | 894 | #endif |
| 893 | 895 | fossil_system(zCmd); |
| 894 | 896 | }else if( strcmp(g.argv[2],"send")==0 ){ |
| 895 | 897 | const char *zFilename = find_option("file","r",1); |
| 898 | + const char *zAs = find_option("as",0,1); | |
| 896 | 899 | const char *zMsg = find_option("message","m",1); |
| 897 | 900 | int allowUnsafe = find_option("unsafe",0,0)!=0; |
| 898 | 901 | const int mFlags = HTTP_GENERIC | HTTP_QUIET | HTTP_NOCOMPRESS; |
| 899 | 902 | int i; |
| 900 | 903 | const char *zPw; |
| @@ -940,13 +943,13 @@ | ||
| 940 | 943 | if( zMsg && zMsg[0] ){ |
| 941 | 944 | blob_appendf(&up,"\r\nContent-Disposition: form-data; name=\"msg\"\r\n" |
| 942 | 945 | "\r\n%s\r\n%s", zMsg, zBoundary); |
| 943 | 946 | } |
| 944 | 947 | if( zFilename && blob_read_from_file(&fcontent, zFilename, ExtFILE)>0 ){ |
| 945 | - char *zFN = mprintf("%s", file_tail(zFilename)); | |
| 948 | + char *zFN = mprintf("%s", file_tail(zAs ? zAs : zFilename)); | |
| 946 | 949 | int i; |
| 947 | - const char *zMime = mimetype_from_name(zFilename); | |
| 950 | + const char *zMime = mimetype_from_name(zFN); | |
| 948 | 951 | for(i=0; zFN[i]; i++){ |
| 949 | 952 | char c = zFN[i]; |
| 950 | 953 | if( fossil_isalnum(c) ) continue; |
| 951 | 954 | if( c=='.' ) continue; |
| 952 | 955 | if( c=='-' ) continue; |
| 953 | 956 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -834,10 +834,12 @@ | |
| 834 | ** |
| 835 | ** This command sends a new message to the chatroom. The message |
| 836 | ** to be sent is determined by arguments as follows: |
| 837 | ** |
| 838 | ** -f|--file FILENAME File to attach to the message |
| 839 | ** -m|--message TEXT Text of the chat message |
| 840 | ** --remote URL Send to this remote URL |
| 841 | ** --unsafe Allow the use of unencrypted http:// |
| 842 | ** |
| 843 | ** > fossil chat url |
| @@ -891,10 +893,11 @@ | |
| 891 | zCmd = mprintf("%s \"%s/chat?cli\" &", zBrowser, zUrl); |
| 892 | #endif |
| 893 | fossil_system(zCmd); |
| 894 | }else if( strcmp(g.argv[2],"send")==0 ){ |
| 895 | const char *zFilename = find_option("file","r",1); |
| 896 | const char *zMsg = find_option("message","m",1); |
| 897 | int allowUnsafe = find_option("unsafe",0,0)!=0; |
| 898 | const int mFlags = HTTP_GENERIC | HTTP_QUIET | HTTP_NOCOMPRESS; |
| 899 | int i; |
| 900 | const char *zPw; |
| @@ -940,13 +943,13 @@ | |
| 940 | if( zMsg && zMsg[0] ){ |
| 941 | blob_appendf(&up,"\r\nContent-Disposition: form-data; name=\"msg\"\r\n" |
| 942 | "\r\n%s\r\n%s", zMsg, zBoundary); |
| 943 | } |
| 944 | if( zFilename && blob_read_from_file(&fcontent, zFilename, ExtFILE)>0 ){ |
| 945 | char *zFN = mprintf("%s", file_tail(zFilename)); |
| 946 | int i; |
| 947 | const char *zMime = mimetype_from_name(zFilename); |
| 948 | for(i=0; zFN[i]; i++){ |
| 949 | char c = zFN[i]; |
| 950 | if( fossil_isalnum(c) ) continue; |
| 951 | if( c=='.' ) continue; |
| 952 | if( c=='-' ) continue; |
| 953 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -834,10 +834,12 @@ | |
| 834 | ** |
| 835 | ** This command sends a new message to the chatroom. The message |
| 836 | ** to be sent is determined by arguments as follows: |
| 837 | ** |
| 838 | ** -f|--file FILENAME File to attach to the message |
| 839 | ** --as FILENAME2 Causes --file FILENAME to be sent with |
| 840 | ** the attachment name FILENAME2 |
| 841 | ** -m|--message TEXT Text of the chat message |
| 842 | ** --remote URL Send to this remote URL |
| 843 | ** --unsafe Allow the use of unencrypted http:// |
| 844 | ** |
| 845 | ** > fossil chat url |
| @@ -891,10 +893,11 @@ | |
| 893 | zCmd = mprintf("%s \"%s/chat?cli\" &", zBrowser, zUrl); |
| 894 | #endif |
| 895 | fossil_system(zCmd); |
| 896 | }else if( strcmp(g.argv[2],"send")==0 ){ |
| 897 | const char *zFilename = find_option("file","r",1); |
| 898 | const char *zAs = find_option("as",0,1); |
| 899 | const char *zMsg = find_option("message","m",1); |
| 900 | int allowUnsafe = find_option("unsafe",0,0)!=0; |
| 901 | const int mFlags = HTTP_GENERIC | HTTP_QUIET | HTTP_NOCOMPRESS; |
| 902 | int i; |
| 903 | const char *zPw; |
| @@ -940,13 +943,13 @@ | |
| 943 | if( zMsg && zMsg[0] ){ |
| 944 | blob_appendf(&up,"\r\nContent-Disposition: form-data; name=\"msg\"\r\n" |
| 945 | "\r\n%s\r\n%s", zMsg, zBoundary); |
| 946 | } |
| 947 | if( zFilename && blob_read_from_file(&fcontent, zFilename, ExtFILE)>0 ){ |
| 948 | char *zFN = mprintf("%s", file_tail(zAs ? zAs : zFilename)); |
| 949 | int i; |
| 950 | const char *zMime = mimetype_from_name(zFN); |
| 951 | for(i=0; zFN[i]; i++){ |
| 952 | char c = zFN[i]; |
| 953 | if( fossil_isalnum(c) ) continue; |
| 954 | if( c=='.' ) continue; |
| 955 | if( c=='-' ) continue; |
| 956 |