ddiff -ub --recursive dillo-0.8.5-i18n-misc-20051127.dist/dpi/Makefile.am dillo-0.8.5-i18n-misc-20051127/dpi/Makefile.am --- dillo-0.8.5-i18n-misc-20051127.dist/dpi/Makefile.am 2005-12-05 06:34:36.000000000 -0800 +++ dillo-0.8.5-i18n-misc-20051127/dpi/Makefile.am 2005-12-05 05:54:32.000000000 -0800 @@ -5,12 +5,14 @@ downloadsdir = $(libdir)/dillo/dpi/downloads ftpdir = $(libdir)/dillo/dpi/ftp httpsdir = $(libdir)/dillo/dpi/https +datauridir = $(libdir)/dillo/dpi/datauri hellodir = $(libdir)/dillo/dpi/hello filedir = $(libdir)/dillo/dpi/file bookmarks_PROGRAMS = bookmarks.dpi downloads_PROGRAMS = downloads.dpi ftp_PROGRAMS = ftp.filter.dpi https_PROGRAMS = https.filter.dpi +datauri_PROGRAMS = datauri.filter.dpi hello_PROGRAMS = hello.filter.dpi file_PROGRAMS = file.dpi @@ -27,5 +29,6 @@ downloads_dpi_SOURCES = downloads.c dpiutil.c dpiutil.h ftp_filter_dpi_SOURCES = ftp.c dpiutil.c dpiutil.h https_filter_dpi_SOURCES = https.c dpiutil.c dpiutil.h +datauri_filter_dpi_SOURCES = hello_filter_dpi_SOURCES = hello.c dpiutil.c dpiutil.h file_dpi_SOURCES = file.c dpiutil.c dpiutil.h diff -ub --recursive dillo-0.8.5-i18n-misc-20051127.dist/dpi/Makefile.in dillo-0.8.5-i18n-misc-20051127/dpi/Makefile.in diff -ub --recursive dillo-0.8.5-i18n-misc-20051127.dist/dpi/datauri.filter.dpi dillo-0.8.5-i18n-misc-20051127/dpi/datauri.filter.dpi --- dillo-0.8.5-i18n-misc-20051127.dist/dpi/datauri.filter.dpi 2005-12-05 06:35:15.000000000 -0800 +++ dillo-0.8.5-i18n-misc-20051127/dpi/datauri.filter.dpi 2005-12-05 06:17:26.000000000 -0800 @@ -0,0 +1,93 @@ +#!/usr/bin/env python + +import urllib + +def dpiunquote(s): + ''' + unquote a dpi parameter value + ''' + if len(s) > 1 and s[0] in ('"', "'") and s[-1] == s[0]: s = s[1:][:-1] + s = '"'.join(s.split('""')) + s = "'".join(s.split("''")) + return s + +def dpiparse(s): + ''' + parse a dpi tag into a dictionary of parameters and values + ''' + if s[:len(''):] != '>': + raise 'missing >' + s = s[len('')] + return dict([ [ dpiunquote(x) for x in kv.split('=', 1) ] for kv in s.split(' ') ]) + +def dpiread(stream): + ''' + read and return an unparsed dpi tag + ''' + s = '' + quoted = '' + while s[-len('>'):] != '>' or quoted: + d = stream.read(1) + if quoted and d == quoted: + quoted = '' + elif not quoted and d in ('"', "'"): + quoted = d + pass + if quoted and d == ' ': + d = '%20' + pass + if not d: + raise EOFError("Missing expected dpi tag.") + s += d + pass + return s + +DPIPREFIX='dpi:/datauri/' +DPIPREFIX2='dpi:/data/' +URIPREFIX='data:' +B64SUFFIX=';base64' + +def main(instream, outstream): + import cgi + dpi = dpiparse(dpiread(instream)) + if dpi['cmd'] != 'open_url': raise 'cmd is not open_url' + if dpi['url'][:len(DPIPREFIX)].lower() == DPIPREFIX.lower(): + dpi['url'] = URIPREFIX + dpi['url'][len(DPIPREFIX):] + pass + elif dpi['url'][:len(DPIPREFIX2)].lower() == DPIPREFIX2.lower(): + dpi['url'] = URIPREFIX + dpi['url'][len(DPIPREFIX2):] + pass + if dpi['url'][:len(URIPREFIX)].lower() != URIPREFIX.lower(): + raise 'not a %s uri' % URIPREFIX + dataurl = dpi['url'][len(URIPREFIX):] + pair = dataurl.split(',', 1) + if len(pair) < 2: pair.append('') + type, data = pair + type = urllib.unquote(type) + if type[-len(B64SUFFIX):].lower() == B64SUFFIX: + try: + data = urllib.unquote(data).decode('base64') + type = type[:-len(B64SUFFIX)] + except Exception, e: + # Treat malformed Base-64 as non-Base-64 + data = urllib.unquote(data) + else: + data = urllib.unquote(data) + pass + if not type: + type = 'text/plain;charset=US-ASCII' + pass + if type[:1] == ';': + type = 'text/plain' + type + pass + outstream.write("" % "''".join(dpi['url'].split("'"))) + outstream.write("Content-Type: " + type + '\n\n' + data) + outstream.flush() + outstream.close() + +if __name__ == '__main__': + import sys + main(sys.stdin, sys.stdout) --- dillo-0.8.5-i18n-misc-20051127.dist/src/IO/Url.c 2005-11-06 05:53:37.000000000 -0800 +++ dillo-0.8.5-i18n-misc-20051127/src/IO/Url.c 2005-12-05 05:40:21.000000000 -0800 @@ -89,10 +89,11 @@ {"dpi" , a_Dpi_ccc}, {"ftp" , a_Dpi_ccc}, #ifdef DILLO_SSL - {"https", a_Https_ccc} + {"https", a_Https_ccc}, #else - {"https" , a_Dpi_ccc} + {"https" , a_Dpi_ccc}, #endif + {"data" , a_Dpi_ccc} }; #define LSIZE (sizeof(cccList) / sizeof(cccList[0])) diff -ub --recursive dillo-0.8.5-i18n-misc-20051127.dist/src/capi.c dillo-0.8.5-i18n-misc-20051127/src/capi.c --- dillo-0.8.5-i18n-misc-20051127.dist/src/capi.c 2005-11-06 06:46:41.000000000 -0800 +++ dillo-0.8.5-i18n-misc-20051127/src/capi.c 2005-12-05 05:56:34.000000000 -0800 @@ -260,6 +260,8 @@ #endif } else if (g_strncasecmp(url_str, "file:", 5) == 0) { server = g_strdup("file"); + } else if (g_strncasecmp(url_str, "data:", 5) == 0) { + server = g_strdup("datauri"); } return ((*server_ptr = server) ? 1 : 0);