From 5825ba704f333af3df36eab870b9e78430a3c724 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 3 Sep 2010 18:22:04 -0400 Subject: [PATCH] Added the ability to handle Base64-encoded URL's. We will use these, along with the new start_reading_at field, to tell search engines how to find the tops of message threads when we eventually begin offering sitemaps. --- webcit/context_loop.c | 1 + webcit/webcit.c | 32 ++++++++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/webcit/context_loop.c b/webcit/context_loop.c index c3e4e4fc9..ca72387d7 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -306,6 +306,7 @@ int ReadHttpSubject(ParsedHttpHdrs *Hdr, StrBuf *Line, StrBuf *Buf) } StrBufAppendBuf(Hdr->this_page, Hdr->HR.ReqLine, 0); + /* chop Filename / query arguments */ Args = strchr(ChrPtr(Hdr->HR.ReqLine), '?'); if (Args == NULL) /* whe're not that picky about params... TODO: this will spoil '&' in filenames.*/ diff --git a/webcit/webcit.c b/webcit/webcit.c index b1d130764..ab8715022 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -119,17 +119,17 @@ void wDumpContent(int print_standard_html_footer) /* * Output HTTP headers and leading HTML for a page */ -void output_headers( int do_httpheaders, /* 1 = output HTTP headers */ +void output_headers( int do_httpheaders, /* 1 = output HTTP headers */ int do_htmlhead, /* 1 = output HTML section and opener */ - int do_room_banner, /* 0=no, 1=yes, + int do_room_banner, /* 0=no, 1=yes, * 2 = I'm going to embed my own, so don't open the - *
either. + *
either. */ int unset_cookies, /* 1 = session is terminating, so unset the cookies */ - int suppress_check, /* 1 = suppress check for instant messages */ - int cache /* 1 = allow browser to cache this page */ + int suppress_check, /* 1 = suppress check for instant messages */ + int cache /* 1 = allow browser to cache this page */ ) { wcsession *WCC = WC; char httpnow[128]; @@ -363,21 +363,21 @@ void begin_ajax_response(void) { wcsession *WCC = WC; FlushStrBuf(WCC->HBuf); - output_headers(0, 0, 0, 0, 0, 0); + output_headers(0, 0, 0, 0, 0, 0); - hprintf("Content-type: text/html; charset=UTF-8\r\n" - "Server: %s\r\n" - "Connection: close\r\n" + hprintf("Content-type: text/html; charset=UTF-8\r\n" + "Server: %s\r\n" + "Connection: close\r\n" , - PACKAGE_STRING); - begin_burst(); + PACKAGE_STRING); + begin_burst(); } /* * print ajax response footer */ void end_ajax_response(void) { - wDumpContent(0); + wDumpContent(0); } @@ -624,6 +624,14 @@ void session_loop(void) Buf = NewStrBuf(); WCC->trailing_javascript = NewStrBuf(); + /* Convert base64-encoded URL's back to plain text */ + if (!strncmp(ChrPtr(WCC->Hdr->this_page), "/B64", 4)) { + StrBufCutLeft(WCC->Hdr->this_page, 4); + StrBufDecodeBase64(WCC->Hdr->this_page); + http_redirect(ChrPtr(WCC->Hdr->this_page)); + goto SKIP_ALL_THIS_CRAP; + } + /* If there are variables in the URL, we must grab them now */ if (WCC->Hdr->PlainArgs != NULL) ParseURLParams(WCC->Hdr->PlainArgs); -- 2.30.2