Only in squid-2.3.STABLE4-noanim/auth_modules/LDAP: Makefile Only in squid-2.3.STABLE4-noanim/auth_modules/NCSA: Makefile Only in squid-2.3.STABLE4-noanim/auth_modules/PAM: Makefile Only in squid-2.3.STABLE4-noanim/auth_modules/SMB: Makefile Only in squid-2.3.STABLE4-noanim/auth_modules: dummy Only in squid-2.3.STABLE4-noanim/auth_modules/getpwnam: Makefile Only in squid-2.3.STABLE4-noanim: config.cache Only in squid-2.3.STABLE4-noanim: config.log Only in squid-2.3.STABLE4-noanim: config.status Only in squid-2.3.STABLE4-noanim/contrib: Makefile Only in squid-2.3.STABLE4-noanim/errors: Makefile Only in squid-2.3.STABLE4-noanim/icons: Makefile Only in squid-2.3.STABLE4-noanim/include: autoconf.h Only in squid-2.3.STABLE4-noanim/include: config.h Only in squid-2.3.STABLE4-noanim/lib: Makefile Only in squid-2.3.STABLE4-noanim: makefile Only in squid-2.3.STABLE4-noanim/scripts: Makefile Only in squid-2.3.STABLE4-noanim/scripts: RunAccel Only in squid-2.3.STABLE4-noanim/scripts: RunCache Only in squid-2.3.STABLE4-noanim/src: Makefile diff -ur squid-2.3.STABLE4/src/client_side.c squid-2.3.STABLE4-noanim/src/client_side.c --- squid-2.3.STABLE4/src/client_side.c Mon Jul 17 22:28:33 2000 +++ squid-2.3.STABLE4-noanim/src/client_side.c Sat Dec 30 11:29:37 2000 @@ -1682,6 +1682,20 @@ } /* reset range iterator */ http->range_iter.pos = HttpHdrRangeInitPos; + + /* Initialize for noAnim processing, which gets rid of all animated + * GIFs. + * 0.1 -- Initial version by Tim Newsome + * 0.2 -- Slight improvement by Tim Newsome + * 0.3 -- Set loop count to 0 by Andreas Koenig and Tim Newsome + */ + http->noAnim.next = 0; + http->noAnim.block_type = -1; + http->noAnim.frame_count = 0; + http->noAnim.slash_r = 1; + http->noAnim.slash_n = 1; + http->noAnim.loopcnt_cand = 0; + http->noAnim.loopcnt_offset = 0; } if (http->request->method == METHOD_HEAD) { if (rep) { @@ -1700,6 +1714,246 @@ http->flags.done_copying = 1; } } + + /* Fuck with the data in case it's an animated GIF. */ + if (http->noAnim.block_type == -1) { + /* We're still in the HTTP header. */ + while (http->out.offset <= http->noAnim.next && + http->out.offset + size >= http->noAnim.next) { + char c = buf[http->noAnim.next - http->out.offset]; + if (c == '\r') { + http->noAnim.slash_r++; + } else if (c == '\n') { + http->noAnim.slash_n++; + } else { + http->noAnim.slash_r = 0; + http->noAnim.slash_n = 0; + } + http->noAnim.next++; + if (http->noAnim.slash_r == http->noAnim.slash_n && + http->noAnim.slash_r > 1) { + http->noAnim.block_type = -2; + http->noAnim.start = http->noAnim.next; + break; + } + } + } + if (http->noAnim.block_type == -2) { + while (http->out.offset <= http->noAnim.next && + http->out.offset + size > http->noAnim.next) { + int offset = http->noAnim.next - http->noAnim.start; + unsigned char c = buf[http->noAnim.next - http->out.offset]; + + /* Check for GIF8[79]a header */ + if (offset == 0 && c != 'G') { + http->noAnim.block_type = -3; + break; + } else if (offset == 1 && c != 'I') { + http->noAnim.block_type = -3; + break; + } else if (offset == 2 && c != 'F') { + http->noAnim.block_type = -3; + break; + } else if (offset == 3 && c != '8') { + http->noAnim.block_type = -3; + break; + } else if (offset == 4 && c != '7' && c != '9') { + http->noAnim.block_type = -3; + break; + } else if (offset == 5 && c != 'a') { + http->noAnim.block_type = -3; + break; + } + if (offset < 5) { + http->noAnim.next++; + } else if (offset == 5) { + http->noAnim.next += 5; + } + + if (offset == 10) { + http->noAnim.next += 3 + (2 << (c&7)) * 3; + } + + if (offset > 10) { + http->noAnim.block_type = c; + http->noAnim.sub_type = -1; + break; + } + } + } + + if (http->noAnim.block_type >= 0) { + while (http->out.offset <= http->noAnim.next && + http->out.offset + size > http->noAnim.next) { + unsigned char c = buf[http->noAnim.next - http->out.offset]; + /* + printf("%s: c=%02x, block_type=%02x, sub_type=%02x\n", + http->uri, c, http->noAnim.block_type, + http->noAnim.sub_type); + */ + + if (http->noAnim.block_type == 0x3b) { + /* EOF block */ + http->noAnim.block_type = -4; + break; + + } else if (http->noAnim.block_type == 0x2c) { + /* GIF data */ + if (http->noAnim.sub_type == -1) { + if (http->noAnim.frame_count++ > 0) { + /* This is what it's all about. Turn subsequent frames + * into EOF blocks. */ + buf[http->noAnim.next - http->out.offset] = 0x3b; + /*printf("%s: WHAM!\n", http->uri);*/ + } + http->noAnim.next += 9; + http->noAnim.sub_type = 0; + } else if (http->noAnim.sub_type == 0) { + if (c & 0x80) + http->noAnim.next += (2 << (c&7)) * 3 + 2; + else + http->noAnim.next += 2; + http->noAnim.sub_type = 1; + } else if (http->noAnim.sub_type == 1) { + /* In the actual compressed data. */ + if (c == 0) { + http->noAnim.sub_type = 2; + http->noAnim.next++; + } else { + http->noAnim.next += c + 1; + } + } else if (http->noAnim.sub_type == 2) { + /* done. find the next block type */ + http->noAnim.sub_type = -1; + http->noAnim.block_type = c; + } + + } else if (http->noAnim.block_type == 0x21) { + /* extension block */ + if (http->noAnim.sub_type == -1) { + http->noAnim.sub_type = -2; + http->noAnim.next++; + } else if (http->noAnim.sub_type == -2) { + http->noAnim.sub_type = c; + if (http->noAnim.sub_type == 0xf9) { + /* graphic control block */ + http->noAnim.next += 7; + } else if (http->noAnim.sub_type == 0xfe) { + /* comment block */ + http->noAnim.next++; + } else if (http->noAnim.sub_type == 0xff) { + /* application specific block */ + http->noAnim.next++; + } else { + http->noAnim.block_type = -3; + break; + } + + } else if (http->noAnim.sub_type == 0xf9) { + /* graphic control block */ + http->noAnim.sub_type = -1; + http->noAnim.block_type = c; + + } else if (http->noAnim.sub_type == 0xfe) { + /* comment block */ + /* ouch, ugly hack. breakage of comments etc... */ + http->noAnim.sub_type = 0xf9; + http->noAnim.next += 2 + c; + + } else if (http->noAnim.sub_type == 0xff) { + /* application specific block */ + if (http->noAnim.loopcnt_cand == 0){ + /* now it is a candidate */ + http->noAnim.loopcnt_cand = 1; + http->noAnim.loopcnt_offset = 0; + /* Only get here once, and that's in the very first + * byte of the block. */ + http->noAnim.slash_r = http->noAnim.next + 1 + c; + /* printf("Now he is a candidate\n"); */ + http->noAnim.next++; + } else if (http->noAnim.loopcnt_cand == 1) { + int i = ++http->noAnim.loopcnt_offset; + /* printf("i[%d]\n", i); */ + if (i < 14){ + /* checking */ + if ( + (i == 1 && c=='N') || + (i == 2 && c=='E') || + (i == 3 && c=='T') || + (i == 4 && c=='S') || + (i == 5 && c=='C') || + (i == 6 && c=='A') || + (i == 7 && c=='P') || + (i == 8 && c=='E') || + (i == 9 && c=='2') || + (i == 10 && c=='.') || + (i == 11 && c=='0') || + (i == 12 && c==0x03) || + (i == 13 && c==0x01) + ){ + /* still a candidate, nothing to do */ + /* printf("Still cand\n"); */ + } else { + /* not a candidate, maybe later */ + /* printf("NOT cand\n"); */ + http->noAnim.loopcnt_cand = -2; + http->noAnim.loopcnt_offset = 0; + http->noAnim.next = http->noAnim.slash_r - 1; + } + } else if (i < 17){ + /* Set loopcnt to 1 */ + if (i==14){ + /* printf("setting 14 to 1\n"); */ + buf[http->noAnim.next-http->out.offset]=0x01; + } else if (i==15){ + /* printf("setting 15 to 0\n"); */ + buf[http->noAnim.next-http->out.offset]=0x00; + } else { + /* printf("setting 16 to 0\n"); */ + buf[http->noAnim.next-http->out.offset]=0x00; + /* Done. Never again become loopcnt candidate */ + http->noAnim.sub_type = 0xf9; + http->noAnim.loopcnt_cand = -1; + } + } else { + /* didn't reach the loopcnt, maybe in another + * block */ + /* printf("Didn't reach\n"); */ + http->noAnim.next = http->noAnim.slash_r - 1; + http->noAnim.loopcnt_cand = -2; + http->noAnim.loopcnt_offset = 0; + } + http->noAnim.next++; + + } else if (http->noAnim.loopcnt_cand == -2 || + http->noAnim.loopcnt_cand == -1) { + if (c == 0) { + /* ouch, ugly hack. breakage of comments etc... */ + if (http->noAnim.loopcnt_cand == -2) + http->noAnim.loopcnt_cand = 0; + http->noAnim.sub_type = 0xf9; + http->noAnim.next++; + } else { + http->noAnim.next += 1 + c; + } + } + + } else { + assert(0); + } + + } else { + http->noAnim.block_type = -3; + break; + } + } + } + /* + if (http->noAnim.block_type == -3) { + printf("%s: No dice.\n", http->uri); + } + */ + /* write headers and/or body if any */ assert(rep || (body_buf && body_size)); /* init mb; put status line and headers if any */ Only in squid-2.3.STABLE4-noanim/src: client_side.c~ Only in squid-2.3.STABLE4-noanim/src: squid.conf diff -ur squid-2.3.STABLE4/src/structs.h squid-2.3.STABLE4-noanim/src/structs.h --- squid-2.3.STABLE4/src/structs.h Wed Mar 29 17:56:57 2000 +++ squid-2.3.STABLE4-noanim/src/structs.h Fri Dec 29 10:33:24 2000 @@ -844,6 +844,17 @@ HierarchyLogEntry hier; }; +struct _noAnim { + int next; + int start; + int block_type; + int sub_type; + int frame_count; + int slash_r, slash_n; + int loopcnt_cand; + int loopcnt_offset; +}; + struct _clientHttpRequest { ConnStateData *conn; request_t *request; /* Parsed URL ... */ @@ -878,6 +889,8 @@ char *location; } redirect; dlink_node active; + + struct _noAnim noAnim; }; struct _ConnStateData { Only in squid-2.3.STABLE4-noanim/src: tags Only in squid-2.3.STABLE4-noanim: tags