summaryrefslogtreecommitdiff
path: root/src/htscore.c
diff options
context:
space:
mode:
authorXavier Roche <xroche@users.noreply.github.com>2014-06-22 13:03:07 +0000
committerXavier Roche <xroche@users.noreply.github.com>2014-06-22 13:03:07 +0000
commit5882b122d1d53c7fb2649b6f7b685022bdc2e5bb (patch)
tree296c79915753ea3f99fd2ca1369e156371655bed /src/htscore.c
parentf27a5f58be10c36b5716f06663667ec40aebb294 (diff)
Handle buggy SVG (Smiling Spectre)
Diffstat (limited to 'src/htscore.c')
-rw-r--r--src/htscore.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/htscore.c b/src/htscore.c
index 2d78638..0157a63 100644
--- a/src/htscore.c
+++ b/src/htscore.c
@@ -429,6 +429,14 @@ if (makeindex_fp) { \
makeindex_done=1; /* ok c'est fait */ \
} while(0)
+/* does it look like XML ? (SVG et al.) */
+static int look_like_xml(const char *s) {
+ return strncmp(s, "<?xml", 5) == 0
+ || strncmp(s, "<!-- ", 5) == 0
+ || strncmp(s, "<svg ", 5) == 0
+ ;
+}
+
// Début de httpmirror, robot
// url1 peut être multiple
int httpmirror(char *url1, httrackp * opt) {
@@ -1180,8 +1188,13 @@ int httpmirror(char *url1, httrackp * opt) {
if (!error) {
if (r.statuscode == HTTP_OK) { // OK (ou 304 en backing)
if (r.adr) { // Written file
- if ((is_hypertext_mime(opt, r.contenttype, urlfil()))
-
+ // Buggy SVG (Smiling Spectre)
+ if (strcmp(r.contenttype, "image/svg+xml") == 0 && !look_like_xml(r.adr)) {
+ // patch it
+ strcpybuff(r.contenttype, "application/octet-stream");
+ is_binary = 1;
+ }
+ else if ((is_hypertext_mime(opt, r.contenttype, urlfil()))
/* Is HTML or Js, .. */
/* NO - real media is real media, not HTML */
/*|| (may_be_hypertext_mime(r.contenttype, urlfil()) && (r.adr) ) */