patch: python filter DPI supporting the "data:" scheme from RFC 2397
Hi! I've been using dillo a bit since the i18n patch became usable, and found that there was one crucial URI scheme missing: "data:", defined in RFC 2397. I used the simple filter DPI model and had something working fairly quickly (thank you all for making that easy!) This works by adding a filter for dpi:/dataurl/... and rewriting data:... to use it, in a fashion similar to the one used by the https filter. The data: URI scheme allows image data (and other linked resources) to be embedded in a web page, so (for example) your DPIs can now trivially embed images, even dynamically-generated ones. It is also supported by the Mozilla family (it's used heavily in GreaseMonkey plugins) and in Konqueror and Safari. Here's an example data: URI (an image) from the RFC: <IMG SRC="data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw AAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFz ByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSp a/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJl ZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uis F81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PH hhx4dbgYKAAA7" ALT="Larry"> The ";base64" is optional, and indicates Base-64 encoded data. The default is unencoded, i.e. just URL-escaped. Here's a non-Base-64 conversion of the same data: <img src="data:image/gif,GIF87a0%000%00%F0%00%00%00%00%00%FF%FF%FF%2C%00 %00%00%000%000%00%00%02%F0%8C%8F%A9%CB%ED%DF%00%9C%0EH%8Bs%B0%B4%AB %0C%86%1E%14%96%A64.%E7%2A%A6%09%8B%1A%A7%2B%AFQIo8%D9%8Ef%D7%F3%80 %5C%C1%C90u%D1%0819%1D%13%A8%14%1E%8E%14M%CC%E7%E4T%9F%B9b%25%2A%AD qyc%99J%87%F0%DE%B8%D7%0F%E7%22%D6%1A%C1%1B%B4%B8%8EJ%96%BFL%F8%3B% 26%92G%C7%27%A7w5%93%05%F5%F4s%13%A7%28%F8%E0%078%B8v%28%A7Xgd%17%C 9%23u%F9%F2q%06We%E6%06z9%89%95%97%86%97%D8%B6%89%C5jh%D5Z%8AT%FA%1 7%98%89%F7I%BA%9A%FB%93K%83%8A%D3%934%BC94C%85%D4%B7%0B%CA%3B%3A%DC wx%AA%F6%E8%AC%17%CDL%D4%E2%1CG%B9D%7B%0C%1C.%9E%ED%B8%D3d3%7B%8D%9 D%AD%C5%D8%94%05%A3%DE%D5%AE%2C%BF%5E%5E%3F%7FW%1F%E5U%B3_%2C%A6%EC %F1%E1%87%1E%1Dn%06%0A%00%00%3B" alt="Larry" /> So far this DPI has only been tested with the i18n-patched version of dillo (I use it to load small test texts in different charsets), but it should theoretically work in regular dillo too. Enjoy, -ben
This updated copy of the patch corrects Content-Type defaulting (text/plain;charset=US-ASCII if empty, text/plain if empty but charset given.) This appears to work with all the Mozilla data: URL test-cases except the JavaScript, CSS, XUL and MP3 ones (the MP3 one deserves further investigation.) See: http://www.mozilla.org/quality/networking/testing/datatests.html On 12/5/05, Ben Wiley Sittler <bsittler@gmail.com> wrote:
Hi! I've been using dillo a bit since the i18n patch became usable, and found that there was one crucial URI scheme missing: "data:", defined in RFC 2397. I used the simple filter DPI model and had something working fairly quickly (thank you all for making that easy!)
This works by adding a filter for dpi:/dataurl/... and rewriting data:... to use it, in a fashion similar to the one used by the https filter.
The data: URI scheme allows image data (and other linked resources) to be embedded in a web page, so (for example) your DPIs can now trivially embed images, even dynamically-generated ones. It is also supported by the Mozilla family (it's used heavily in GreaseMonkey plugins) and in Konqueror and Safari.
Here's an example data: URI (an image) from the RFC:
<IMG SRC="data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw AAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFz ByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSp a/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJl ZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uis F81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PH hhx4dbgYKAAA7" ALT="Larry">
The ";base64" is optional, and indicates Base-64 encoded data. The default is unencoded, i.e. just URL-escaped. Here's a non-Base-64 conversion of the same data:
<img src="data:image/gif,GIF87a0%000%00%F0%00%00%00%00%00%FF%FF%FF%2C%00 %00%00%000%000%00%00%02%F0%8C%8F%A9%CB%ED%DF%00%9C%0EH%8Bs%B0%B4%AB %0C%86%1E%14%96%A64.%E7%2A%A6%09%8B%1A%A7%2B%AFQIo8%D9%8Ef%D7%F3%80 %5C%C1%C90u%D1%0819%1D%13%A8%14%1E%8E%14M%CC%E7%E4T%9F%B9b%25%2A%AD qyc%99J%87%F0%DE%B8%D7%0F%E7%22%D6%1A%C1%1B%B4%B8%8EJ%96%BFL%F8%3B% 26%92G%C7%27%A7w5%93%05%F5%F4s%13%A7%28%F8%E0%078%B8v%28%A7Xgd%17%C 9%23u%F9%F2q%06We%E6%06z9%89%95%97%86%97%D8%B6%89%C5jh%D5Z%8AT%FA%1 7%98%89%F7I%BA%9A%FB%93K%83%8A%D3%934%BC94C%85%D4%B7%0B%CA%3B%3A%DC wx%AA%F6%E8%AC%17%CDL%D4%E2%1CG%B9D%7B%0C%1C.%9E%ED%B8%D3d3%7B%8D%9 D%AD%C5%D8%94%05%A3%DE%D5%AE%2C%BF%5E%5E%3F%7FW%1F%E5U%B3_%2C%A6%EC %F1%E1%87%1E%1Dn%06%0A%00%00%3B" alt="Larry" />
So far this DPI has only been tested with the i18n-patched version of dillo (I use it to load small test texts in different charsets), but it should theoretically work in regular dillo too.
Enjoy, -ben
One more update (this should be the last for awhile) -- this fixes crashes caused by stalled incomplete reads (due to EAGAIN on the C side.) I've attached the updated python filter in addition to the full patch since only the python changed. On 12/5/05, Ben Wiley Sittler <bsittler@gmail.com> wrote:
This updated copy of the patch corrects Content-Type defaulting (text/plain;charset=US-ASCII if empty, text/plain if empty but charset given.)
This appears to work with all the Mozilla data: URL test-cases except the JavaScript, CSS, XUL and MP3 ones (the MP3 one deserves further investigation.) See:
http://www.mozilla.org/quality/networking/testing/datatests.html
On 12/5/05, Ben Wiley Sittler <bsittler@gmail.com> wrote:
Hi! I've been using dillo a bit since the i18n patch became usable, and found that there was one crucial URI scheme missing: "data:", defined in RFC 2397. I used the simple filter DPI model and had something working fairly quickly (thank you all for making that easy!)
This works by adding a filter for dpi:/dataurl/... and rewriting data:... to use it, in a fashion similar to the one used by the https filter.
The data: URI scheme allows image data (and other linked resources) to be embedded in a web page, so (for example) your DPIs can now trivially embed images, even dynamically-generated ones. It is also supported by the Mozilla family (it's used heavily in GreaseMonkey plugins) and in Konqueror and Safari.
Here's an example data: URI (an image) from the RFC:
<IMG SRC="data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw AAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFz ByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSp a/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJl ZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uis F81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PH hhx4dbgYKAAA7" ALT="Larry">
The ";base64" is optional, and indicates Base-64 encoded data. The default is unencoded, i.e. just URL-escaped. Here's a non-Base-64 conversion of the same data:
<img src="data:image/gif,GIF87a0%000%00%F0%00%00%00%00%00%FF%FF%FF%2C%00 %00%00%000%000%00%00%02%F0%8C%8F%A9%CB%ED%DF%00%9C%0EH%8Bs%B0%B4%AB %0C%86%1E%14%96%A64.%E7%2A%A6%09%8B%1A%A7%2B%AFQIo8%D9%8Ef%D7%F3%80 %5C%C1%C90u%D1%0819%1D%13%A8%14%1E%8E%14M%CC%E7%E4T%9F%B9b%25%2A%AD qyc%99J%87%F0%DE%B8%D7%0F%E7%22%D6%1A%C1%1B%B4%B8%8EJ%96%BFL%F8%3B% 26%92G%C7%27%A7w5%93%05%F5%F4s%13%A7%28%F8%E0%078%B8v%28%A7Xgd%17%C 9%23u%F9%F2q%06We%E6%06z9%89%95%97%86%97%D8%B6%89%C5jh%D5Z%8AT%FA%1 7%98%89%F7I%BA%9A%FB%93K%83%8A%D3%934%BC94C%85%D4%B7%0B%CA%3B%3A%DC wx%AA%F6%E8%AC%17%CDL%D4%E2%1CG%B9D%7B%0C%1C.%9E%ED%B8%D3d3%7B%8D%9 D%AD%C5%D8%94%05%A3%DE%D5%AE%2C%BF%5E%5E%3F%7FW%1F%E5U%B3_%2C%A6%EC %F1%E1%87%1E%1Dn%06%0A%00%00%3B" alt="Larry" />
So far this DPI has only been tested with the i18n-patched version of dillo (I use it to load small test texts in different charsets), but it should theoretically work in regular dillo too.
Enjoy, -ben
Hi Ben, Sorry for the late answer. I was way busy w/paper-work. :-P On Mon, Dec 05, 2005 at 03:43:07PM -0800, Ben Wiley Sittler wrote:
One more update (this should be the last for awhile) -- this fixes crashes caused by stalled incomplete reads (due to EAGAIN on the C side.)
I've attached the updated python filter in addition to the full patch since only the python changed.
Thanks, I gave the script a review. Probably I'll rewrite it in C and keep the python codebase as a starting point for other dpis. OTOH, It's good to have a python dpi example that shows it's easy to develop dpis.
On 12/5/05, Ben Wiley Sittler <bsittler@gmail.com> wrote:
This updated copy of the patch corrects Content-Type defaulting (text/plain;charset=US-ASCII if empty, text/plain if empty but charset given.)
This appears to work with all the Mozilla data: URL test-cases except the JavaScript, CSS, XUL and MP3 ones (the MP3 one deserves further investigation.) See:
http://www.mozilla.org/quality/networking/testing/datatests.html
Hmmm, I'll try to upload a C translation soon. Can you continue from there? -- Cheers Jorge.-
On Mon, 5 Dec 2005 07:58:11 -0800 Ben Wiley Sittler <bsittler@gmail.com> wrote:
and found that there was one crucial URI scheme missing: "data:", defined in RFC 2397. I used the simple filter DPI model and had something working fairly quickly (thank you all for making that easy!)
nifty! something i've been looking for before. but... i love how firing up a python interpreter (/compiler/vm/...) (or any external process) and passing it the data just to decode it fits with the general efficiency of data: (which i'd consider the main argument for using it)...
Enjoy, -ben
Thorben
Well, you choose to use it or not. And you choose to give an alternative(show me the code :P). It is not a complex task: cp IO/about.c IO/data.c and start with that. Diego Sáenz/DarkSpirit El Tue, 6 Dec 2005 03:41:33 +0100 Thorben Thuermer <r00t@informatik.uni-bremen.de> escribio:
On Mon, 5 Dec 2005 07:58:11 -0800 Ben Wiley Sittler <bsittler@gmail.com> wrote:
and found that there was one crucial URI scheme missing: "data:", defined in RFC 2397. I used the simple filter DPI model and had something working fairly quickly (thank you all for making that easy!)
nifty! something i've been looking for before.
but... i love how firing up a python interpreter (/compiler/vm/...) (or any external process) and passing it the data just to decode it fits with the general efficiency of data: (which i'd consider the main argument for using it)...
Enjoy, -ben
Thorben
_______________________________________________ Dillo-dev mailing list Dillo-dev@dillo.org http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
El Mon, 5 Dec 2005 07:58:11 -0800 Ben Wiley Sittler <bsittler@gmail.com> escribio:
Hi! I've been using dillo a bit since the i18n patch became usable, and found that there was one crucial URI scheme missing: "data:", defined in RFC 2397. I used the simple filter DPI model and had something working fairly quickly (thank you all for making that easy!)
Great, i try to do the same for the xproto patch with a shell script, but only support base 64 and forget it.
This works by adding a filter for dpi:/dataurl/... and rewriting data:... to use it, in a fashion similar to the one used by the https filter.
The data: URI scheme allows image data (and other linked resources) to be embedded in a web page, so (for example) your DPIs can now trivially embed images, even dynamically-generated ones. It is also supported by the Mozilla family (it's used heavily in GreaseMonkey plugins) and in Konqueror and Safari.
I think i will use this feature for the prefs plug-in.
Here's an example data: URI (an image) from the RFC:
<IMG SRC="data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAw AAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFz ByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSp a/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJl ZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uis F81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PH hhx4dbgYKAAA7" ALT="Larry">
The ";base64" is optional, and indicates Base-64 encoded data. The default is unencoded, i.e. just URL-escaped. Here's a non-Base-64 conversion of the same data:
<img src="data:image/gif,GIF87a0%000%00%F0%00%00%00%00%00%FF%FF%FF%2C%00 %00%00%000%000%00%00%02%F0%8C%8F%A9%CB%ED%DF%00%9C%0EH%8Bs%B0%B4%AB %0C%86%1E%14%96%A64.%E7%2A%A6%09%8B%1A%A7%2B%AFQIo8%D9%8Ef%D7%F3%80 %5C%C1%C90u%D1%0819%1D%13%A8%14%1E%8E%14M%CC%E7%E4T%9F%B9b%25%2A%AD qyc%99J%87%F0%DE%B8%D7%0F%E7%22%D6%1A%C1%1B%B4%B8%8EJ%96%BFL%F8%3B% 26%92G%C7%27%A7w5%93%05%F5%F4s%13%A7%28%F8%E0%078%B8v%28%A7Xgd%17%C 9%23u%F9%F2q%06We%E6%06z9%89%95%97%86%97%D8%B6%89%C5jh%D5Z%8AT%FA%1 7%98%89%F7I%BA%9A%FB%93K%83%8A%D3%934%BC94C%85%D4%B7%0B%CA%3B%3A%DC wx%AA%F6%E8%AC%17%CDL%D4%E2%1CG%B9D%7B%0C%1C.%9E%ED%B8%D3d3%7B%8D%9 D%AD%C5%D8%94%05%A3%DE%D5%AE%2C%BF%5E%5E%3F%7FW%1F%E5U%B3_%2C%A6%EC %F1%E1%87%1E%1Dn%06%0A%00%00%3B" alt="Larry" />
So far this DPI has only been tested with the i18n-patched version of dillo (I use it to load small test texts in different charsets), but it should theoretically work in regular dillo too.
Enjoy, -ben
Goodbye Diego
participants (4)
-
Ben Wiley Sittler
-
Diego Sáenz
-
Jorge Arellano Cid
-
Thorben Thuermer