[1mdiff --git a/src/gmutil.c b/src/gmutil.c[m
[1mindex fda8489b..9bd74ee0 100644[m
[1m--- a/src/gmutil.c[m
[1m+++ b/src/gmutil.c[m
[36m@@ -22,10 +22,12 @@[m [mSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */[m
[m
#include "gmutil.h"[m
[m
[31m-#include <the_Foundation/regexp.h>[m
[32m+[m[32m#include <the_Foundation/file.h>[m
[32m+[m[32m#include <the_Foundation/fileinfo.h>[m
#include <the_Foundation/object.h>[m
#include <the_Foundation/path.h>[m
#include <the_Foundation/regexp.h>[m
[32m+[m[32m#include <the_Foundation/regexp.h>[m
[m
iRegExp *newGemtextLink_RegExp(void) {[m
return new_RegExp("=>\\s*([^\\s]+)(\\s.*)?", 0);[m
[36m@@ -513,18 +515,6 @@[m [mconst char *mediaType_Path(const iString *path) {[m
if (endsWithCase_String(path, ".gmi") || endsWithCase_String(path, ".gemini")) {[m
return "text/gemini; charset=utf-8";[m
}[m
[31m- /* TODO: It would be better to default to text/plain, but switch to[m
[31m- application/octet-stream if the contents fail to parse as UTF-8. */[m
[31m- else if (endsWithCase_String(path, ".txt") ||[m
[31m- endsWithCase_String(path, ".md") ||[m
[31m- endsWithCase_String(path, ".c") ||[m
[31m- endsWithCase_String(path, ".h") ||[m
[31m- endsWithCase_String(path, ".cc") ||[m
[31m- endsWithCase_String(path, ".hh") ||[m
[31m- endsWithCase_String(path, ".cpp") ||[m
[31m- endsWithCase_String(path, ".hpp")) {[m
[31m- return "text/plain";[m
[31m- }[m
else if (endsWithCase_String(path, ".pem")) {[m
return "application/x-pem-file";[m
}[m
[36m@@ -558,7 +548,30 @@[m [mconst char *mediaType_Path(const iString *path) {[m
else if (endsWithCase_String(path, ".mid")) {[m
return "audio/midi";[m
}[m
[31m- return "application/octet-stream";[m
[32m+[m[32m else if (endsWithCase_String(path, ".txt") ||[m
[32m+[m[32m endsWithCase_String(path, ".md") ||[m
[32m+[m[32m endsWithCase_String(path, ".c") ||[m
[32m+[m[32m endsWithCase_String(path, ".h") ||[m
[32m+[m[32m endsWithCase_String(path, ".cc") ||[m
[32m+[m[32m endsWithCase_String(path, ".hh") ||[m
[32m+[m[32m endsWithCase_String(path, ".cpp") ||[m
[32m+[m[32m endsWithCase_String(path, ".hpp")) {[m
[32m+[m[32m return "text/plain";[m
[32m+[m[32m }[m
[32m+[m[32m const char *mtype = "application/octet-stream";[m
[32m+[m[32m /* If the file is reasonably small and looks like UTF-8, we'll display it as text/plain. */[m
[32m+[m[32m if (fileExists_FileInfo(path) && fileSize_FileInfo(path) <= 5000000) {[m
[32m+[m[32m iFile *f = new_File(path);[m
[32m+[m[32m if (open_File(f, readOnly_FileMode)) {[m
[32m+[m[32m iBlock *content = readAll_File(f);[m
[32m+[m[32m if (isUtf8_Rangecc(range_Block(content))) {[m
[32m+[m[32m mtype = "text/plain; charset=utf-8";[m
[32m+[m[32m }[m
[32m+[m[32m delete_Block(content);[m
[32m+[m[32m }[m
[32m+[m[32m iRelease(f);[m
[32m+[m[32m }[m
[32m+[m[32m return mtype;[m
}[m
[m
static void replaceAllChars_String_(iString *d, char c, const char *replacement) {[m
text/plain
This content has been proxied by September (ba2dc).