From: Wilfried Göesgens Date: Mon, 28 Jul 2008 21:22:02 +0000 (+0000) Subject: * read static/server files directly into the outbuffer X-Git-Tag: v7.86~2071 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=d0e2028fa275ff13c4906aabdd190fcec143b172 * read static/server files directly into the outbuffer * resynced debian chagelog --- diff --git a/webcit/availability.c b/webcit/availability.c index 097725523..156137b1b 100644 --- a/webcit/availability.c +++ b/webcit/availability.c @@ -13,13 +13,13 @@ icalcomponent *get_freebusy_for_user(char *who) { long nLines; char buf[SIZ]; - StrBuf *serialized_fb = NULL; + StrBuf *serialized_fb = NewStrBuf(); icalcomponent *fb = NULL; serv_printf("ICAL freebusy|%s", who); serv_getln(buf, sizeof buf); if (buf[0] == '1') { - serialized_fb = read_server_text(&nLines); + read_server_text(serialized_fb, &nLines); } if (serialized_fb == NULL) { diff --git a/webcit/calendar.c b/webcit/calendar.c index 61d621993..7b6374eed 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -1073,7 +1073,6 @@ void save_event(void) { void do_freebusy(char *req) { char who[SIZ]; char buf[SIZ]; - StrBuf *fb; int len; long lines; @@ -1103,9 +1102,8 @@ void do_freebusy(char *req) { return; } - fb = read_server_text(&lines); - http_transmit_thing(fb, "text/calendar", 0); - FreeStrBuf(&fb); + read_server_text(WC->WBuf, &lines); + http_transmit_thing("text/calendar", 0); } diff --git a/webcit/debian/changelog b/webcit/debian/changelog index 39c275194..e7940ce08 100644 --- a/webcit/debian/changelog +++ b/webcit/debian/changelog @@ -1,3 +1,68 @@ +webcit (7.37-36) stable; urgency=low + + * fix tiny JS error anoying HTTP IM Users + + -- Wilfried Goesgens Wed, 16 Jul 2008 14:00:00 +0002 + +webcit (7.37-35) stable; urgency=low + + * tiny bugfix with i18n makefiles + + -- Wilfried Goesgens Sun, 22 Jun 2008 22:00:00 +0002 + +webcit (7.37-34) stable; urgency=low + + * new upstream version + + -- Wilfried Goesgens Thu, 19 Jun 2008 22:00:00 +0002 + +webcit (7.36-33) stable; urgency=low + + * new upstream version + + -- Wilfried Goesgens Fri, 30 May 2008 19:00:00 +0002 + +webcit (7.35-32) stable; urgency=low + + * fix prototype package integration + * updated brazillian translation + + -- Wilfried Goesgens Wed, 22 Apr 2008 8:00:00 +0001 +webcit (7.35-31) stable; urgency=low + + * New citadel version + + -- Wilfried Goesgens Tue, 22 Apr 2008 19:00:00 +0002 + +webcit (7.34-29) stable; urgency=high + + * fix bug in addressbook popup + + -- Wilfried Goesgens Wed, 5 Mar 2008 22:00:00 +0001 + +webcit (7.33-28) stable; urgency=high + + * adjusted license; new sorting in lists + + -- Wilfried Goesgens Mo, 3 Mar 2008 22:00:00 +0001 + +webcit (7.31-27) stable; urgency=high + + * initial mime detection support + * don't nail the users to GIF + + -- Wilfried Goesgens Tue, 12 Feb 2008 0:00:00 +0001 + +webcit (7.30-26) stable; urgency=high + + * Fix room admin dialog + + -- Wilfried Goesgens Wed, 6 Feb 2008 20:00:00 +0001 +webcit (7.30-25) stable; urgency=high + + * New citadel version. + + -- Wilfried Goesgens Fri, 1 Feb 2008 10:00:00 +0001 webcit (7.24-24) stable; urgency=high * fixed missing locales and image calculation diff --git a/webcit/downloads.c b/webcit/downloads.c index 600d89de0..23bf5f801 100644 --- a/webcit/downloads.c +++ b/webcit/downloads.c @@ -383,7 +383,6 @@ void display_mime_icon(void) void download_file(void) { - StrBuf *Buf; char buf[256]; off_t bytes; char content_type[256]; @@ -406,10 +405,10 @@ void download_file(void) extract_token(content_type, &buf[4], 3, '|', sizeof content_type); } output_headers(0, 0, 0, 0, 0, 0); - Buf = read_server_binary(bytes); + read_server_binary(WC->WBuf, bytes); serv_puts("CLOS"); serv_getln(buf, sizeof buf); - http_transmit_thing(Buf, content_type, 0); + http_transmit_thing(content_type, 0); free(content); } else { hprintf("HTTP/1.1 404 %s\n", &buf[4]); diff --git a/webcit/messages.c b/webcit/messages.c index 903408964..e7f007484 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -1413,7 +1413,7 @@ void print_message(void) { hprintf("Content-type: text/html\r\n" "Server: %s\r\n" - "Connection: close\r\n" + "Connection: close\r\n", PACKAGE_STRING); begin_burst(); diff --git a/webcit/serv_func.c b/webcit/serv_func.c index a5604c225..50a7ab8b4 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -341,24 +341,25 @@ void server_to_text() * server READ commands. * \return the read content as StrBuf */ -StrBuf *read_server_binary(size_t total_len) +int read_server_binary(StrBuf *Ret, size_t total_len) { char buf[SIZ]; size_t bytes = 0; size_t thisblock = 0; StrBuf *Buf; - StrBuf *Ret = NULL; - - Buf = NewStrBuf(); + Buf = NewStrBuf(); + if (Ret == NULL) + return -1; + while (bytes < total_len) { thisblock = 4095; if ((total_len - bytes) < thisblock) { thisblock = total_len - bytes; if (thisblock == 0) { - FreeStrBuf(&Ret); + FlushStrBuf(Ret); FreeStrBuf(&Buf); - return NULL; + return -1; } } serv_printf("READ %d|%d", (int)bytes, (int)thisblock); @@ -369,22 +370,21 @@ StrBuf *read_server_binary(size_t total_len) StrBufCutLeft(Buf, 4); //thisblock = (size_t)atoi(&buf[4]); thisblock = StrTol(Buf); if (!WC->connected) { - FreeStrBuf(&Ret); + FlushStrBuf(Ret); FreeStrBuf(&Buf); - return NULL; + return -1; } - if (Ret == NULL) Ret = NewStrBuf(); StrBuf_ServGetBLOB(Ret, thisblock); bytes += thisblock; } else { FreeStrBuf(&Buf); lprintf(3, "Error: %s\n", &buf[4]); - return NULL; + return -1; } } } - return Ret; + return StrLength(Ret); } @@ -393,27 +393,27 @@ StrBuf *read_server_binary(size_t total_len) * usual 000 terminator is found. Caller is responsible for freeing * the returned pointer. */ -StrBuf *read_server_text(long *nLines) +int read_server_text(StrBuf *Buf, long *nLines) { struct wcsession *WCC = WC; - StrBuf *Buf; long nRead; + long nTotal = 0; long nlines; - const char *buf; - Buf = NewStrBuf(); - buf = ChrPtr(Buf); nlines = 0; while ((WCC->serv_sock!=-1) && - (nRead = StrBuf_ServGetln(Buf)), - (nRead >= 0) && - (buf += nRead), (strcmp(buf, "000") != 0)) { - + (nRead = StrBuf_ServGetln(Buf), (nRead >= 0) )) + { + if (strcmp(ChrPtr(Buf) + nTotal, "000") != 0) { + StrBufCutRight(Buf, nRead); + break; + } + nTotal += nRead; nlines ++; } *nLines = nlines; - return Buf; + return nTotal; } diff --git a/webcit/webcit.c b/webcit/webcit.c index 27edb1a3d..7638cbf20 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -764,7 +764,7 @@ void http_redirect(const char *whichpage) { /* * Output a piece of content to the web browser using conformant HTTP and MIME semantics */ -void http_transmit_thing(StrBuf *thing, const char *content_type, +void http_transmit_thing(const char *content_type, int is_static) { output_headers(0, 0, 0, 0, 0, is_static); @@ -775,9 +775,7 @@ void http_transmit_thing(StrBuf *thing, const char *content_type, content_type, PACKAGE_STRING); - WC->WBuf = thing; end_burst(); - WC->WBuf = NULL; } /* @@ -824,7 +822,6 @@ void output_static(char *what) struct stat statbuf; off_t bytes; off_t count = 0; - StrBuf *Buf; const char *content_type; int len; const char *Err; @@ -851,17 +848,10 @@ void output_static(char *what) count = 0; bytes = statbuf.st_size; - Buf = NewStrBufPlain(NULL, bytes + 2); - if (Buf == NULL) { - lprintf(9, "output_static('%s') -- MALLOC FAILED (%s) --\n", what, strerror(errno)); - hprintf("HTTP/1.1 500 internal server error\r\n"); - hprintf("Content-Type: text/plain\r\n"); - end_burst(); - return; - } -/// StrBufAppendBuf(Buf, WC->WBuf, 0); - if (StrBufReadBLOB(Buf, &fd, 1, bytes, &Err) < 0) + + if (StrBufReadBLOB(WC->WBuf, &fd, 1, bytes, &Err) < 0) { + if (fd > 0) close(fd); lprintf(9, "output_static('%s') -- FREAD FAILED (%s) --\n", what, strerror(errno)); hprintf("HTTP/1.1 500 internal server error \r\n"); hprintf("Content-Type: text/plain\r\n"); @@ -872,8 +862,7 @@ void output_static(char *what) close(fd); lprintf(9, "output_static('%s') %s\n", what, content_type); - http_transmit_thing(Buf, content_type, 1); - FreeStrBuf(&Buf); + http_transmit_thing(content_type, 1); } if (yesbstr("force_close_session")) { end_webcit_session(); @@ -886,12 +875,12 @@ void output_static(char *what) */ void output_image() { + struct wcsession *WCC = WC; char buf[SIZ]; char *xferbuf = NULL; off_t bytes; const char *MimeType; - StrBuf *Buf; - + serv_printf("OIMG %s|%s", bstr("name"), bstr("parm")); serv_getln(buf, sizeof buf); if (buf[0] == '2') { @@ -900,19 +889,17 @@ void output_image() /** Read it from the server */ - Buf = read_server_binary(bytes); - serv_puts("CLOS"); - serv_getln(buf, sizeof buf); - - MimeType = GuessMimeType (ChrPtr(Buf), StrLength(Buf)); - /** Write it to the browser */ - if (!IsEmptyStr(MimeType)) - { - http_transmit_thing(Buf, - MimeType, - 0); - FreeStrBuf(&Buf); - return; + if (read_server_binary(WCC->WBuf, bytes) > 0) { + serv_puts("CLOS"); + serv_getln(buf, sizeof buf); + + MimeType = GuessMimeType (ChrPtr(WCC->WBuf), StrLength(WCC->WBuf)); + /** Write it to the browser */ + if (!IsEmptyStr(MimeType)) + { + http_transmit_thing(MimeType, 0); + return; + } } /* hm... unknown mimetype? fallback to blank gif */ } @@ -935,35 +922,32 @@ void display_vcard_photo_img(void) long msgnum = 0L; char *vcard; struct vCard *v; - char *xferbuf; char *photosrc; - int decoded; const char *contentType; - StrBuf *Buf; + struct wcsession *WCC = WC; - msgnum = StrTol(WC->UrlFragment1); + msgnum = StrTol(WCC->UrlFragment1); vcard = load_mimepart(msgnum,"1"); v = vcard_load(vcard); photosrc = vcard_get_prop(v, "PHOTO", 1,0,0); - xferbuf = malloc(strlen(photosrc)); - if (xferbuf == NULL) { - lprintf(5, "xferbuf malloc failed\n"); + FlushStrBuf(WCC->WBuf); + StrBufAppendBufPlain(WCC->WBuf, photosrc, -1, 0); + if (StrBufDecodeBase64(WCC->WBuf) <= 0) { + FlushStrBuf(WCC->WBuf); + + hprintf("HTTP/1.1 500 %s\n","Unable to get photo"); + output_headers(0, 0, 0, 0, 0, 0); + hprintf("Content-Type: text/plain\r\n"); + wprintf(_("Could Not decode vcard photo\n")); + end_burst(); return; } - memset(xferbuf, 1, SIZ); - decoded = CtdlDecodeBase64( - xferbuf, - photosrc, - strlen(photosrc)); - contentType = GuessMimeType(xferbuf, decoded); - Buf = _NewConstStrBuf(xferbuf, decoded); - http_transmit_thing(Buf, contentType, 0); + contentType = GuessMimeType(ChrPtr(WCC->WBuf), StrLength(WCC->WBuf)); + http_transmit_thing(contentType, 0); free(v); free(photosrc); - free(xferbuf); - FreeStrBuf(&Buf); } /* @@ -984,7 +968,6 @@ void mimepart(const char *msgnum, const char *partnum, int force_download) serv_printf("OPNA %s|%s", msgnum, partnum); serv_getln(buf, sizeof buf); if (buf[0] == '2') { - StrBuf *Buf; bytes = extract_long(&buf[4], 0); content = malloc(bytes + 2); if (force_download) { @@ -995,11 +978,10 @@ void mimepart(const char *msgnum, const char *partnum, int force_download) } output_headers(0, 0, 0, 0, 0, 0); - Buf = read_server_binary(bytes); + read_server_binary(WC->WBuf, bytes); serv_puts("CLOS"); serv_getln(buf, sizeof buf); - http_transmit_thing(Buf, content_type, 0); - FreeStrBuf(&Buf); + http_transmit_thing(content_type, 0); } else { hprintf("HTTP/1.1 404 %s\n", &buf[4]); output_headers(0, 0, 0, 0, 0, 0); @@ -1378,9 +1360,14 @@ void session_loop(struct httprequest *req) strcpy(browser_host, ""); WCC= WC; + if (WCC->WBuf == NULL) + WCC->WBuf = NewStrBuf(); + FlushStrBuf(WCC->WBuf); + if (WCC->HBuf == NULL) WCC->HBuf = NewStrBuf(); FlushStrBuf(WCC->HBuf); + WCC->upload_length = 0; WCC->upload = NULL; WCC->is_mobile = 0; diff --git a/webcit/webcit.h b/webcit/webcit.h index d57b83808..572b42ff0 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -703,13 +703,13 @@ void initialize_locales(void); extern char *months[]; extern char *days[]; -StrBuf *read_server_binary(size_t total_len); +int read_server_binary(StrBuf *Ret, size_t total_len); int StrBuf_ServGetBLOB(StrBuf *buf, long BlobSize); -StrBuf *read_server_text(long *nLines); +int read_server_text(StrBuf *Buf, long *nLines);; int goto_config_room(void); long locate_user_vcard(char *username, long usernum); void sleeeeeeeeeep(int); -void http_transmit_thing(StrBuf *thing, const char *content_type, int is_static); +void http_transmit_thing(const char *content_type, int is_static); long unescape_input(char *buf); void do_selected_iconbar(void); int CtdlDecodeQuotedPrintable(char *decoded, char *encoded, int sourcelen);