Fossil SCM
/fileedit_content now only uses application/octet-stream for files which explicitly have that type via mimetype_by_name() or which look like binary content, falling back to text/plain, per suggestion in the discussion thread.
Commit
4270ecb3a2f567d5402b7ac4e264629248bf25caa4400027dca520f371bf05ee
Parent
f54ac21745eb59e…
1 file changed
+8
-1
+8
-1
| --- src/fileedit.c | ||
| +++ src/fileedit.c | ||
| @@ -1143,11 +1143,18 @@ | ||
| 1143 | 1143 | zFilename, &frid)){ |
| 1144 | 1144 | return; |
| 1145 | 1145 | } |
| 1146 | 1146 | zMime = mimetype_from_name(zFilename); |
| 1147 | 1147 | content_get(frid, &content); |
| 1148 | - cgi_set_content_type(zMime ? zMime : "application/octet-stream"); | |
| 1148 | + if(0==zMime){ | |
| 1149 | + if(looks_like_binary(&content)){ | |
| 1150 | + zMime = "application/octet-stream"; | |
| 1151 | + }else{ | |
| 1152 | + zMime = "text/plain"; | |
| 1153 | + } | |
| 1154 | + } | |
| 1155 | + cgi_set_content_type(zMime); | |
| 1149 | 1156 | cgi_set_content(&content); |
| 1150 | 1157 | } |
| 1151 | 1158 | |
| 1152 | 1159 | /* |
| 1153 | 1160 | ** WEBPAGE: fileedit_preview |
| 1154 | 1161 |
| --- src/fileedit.c | |
| +++ src/fileedit.c | |
| @@ -1143,11 +1143,18 @@ | |
| 1143 | zFilename, &frid)){ |
| 1144 | return; |
| 1145 | } |
| 1146 | zMime = mimetype_from_name(zFilename); |
| 1147 | content_get(frid, &content); |
| 1148 | cgi_set_content_type(zMime ? zMime : "application/octet-stream"); |
| 1149 | cgi_set_content(&content); |
| 1150 | } |
| 1151 | |
| 1152 | /* |
| 1153 | ** WEBPAGE: fileedit_preview |
| 1154 |
| --- src/fileedit.c | |
| +++ src/fileedit.c | |
| @@ -1143,11 +1143,18 @@ | |
| 1143 | zFilename, &frid)){ |
| 1144 | return; |
| 1145 | } |
| 1146 | zMime = mimetype_from_name(zFilename); |
| 1147 | content_get(frid, &content); |
| 1148 | if(0==zMime){ |
| 1149 | if(looks_like_binary(&content)){ |
| 1150 | zMime = "application/octet-stream"; |
| 1151 | }else{ |
| 1152 | zMime = "text/plain"; |
| 1153 | } |
| 1154 | } |
| 1155 | cgi_set_content_type(zMime); |
| 1156 | cgi_set_content(&content); |
| 1157 | } |
| 1158 | |
| 1159 | /* |
| 1160 | ** WEBPAGE: fileedit_preview |
| 1161 |