how to display C sources in Chromium (file:/// only)

Evan Martin evan at chromium.org
Mon Apr 30 15:47:22 UTC 2012


On Sat, Apr 28, 2012 at 7:47 AM, Luigi Rizzo <rizzo at iet.unipi.it> wrote:
> (hoping this is of interest for hackers- too)
>
> One of the most annoying features of chromium is that it downloads
> instead of displaying various types of files (.c, .h and so on).

This has long annoyed me too!

> it seems that a partial fix can be achieved by arring the list of
> types we want to display to the array
>
>    static const char* const supported_non_image_types[] = {
>        ...
> +       "text/x-csrc",
> +       "text/x-chdr",
>        ...
>    }

There's a comment at the end of the block:
  // Note: ADDING a new type here will probably render it AS HTML. This can
  // result in cross site scripting.
I wonder how to tell?

If you follow the references back from the definition of this variable
it appears to end up used here:
http://code.google.com/searchframe#OAMlx_jo-ck/src/third_party/WebKit/Source/WebCore/loader/FrameLoader.cpp&exact_package=chromium&ct=rc&cd=10&q=IsSupportedNonImageMimeType&l=859
which just indicates it's used when WebKit is deciding whether to
inline the content or not.

It seems to me like you could adjust the code in
MimeUtil::IsSupportedNonImageMimeType to always return true for any
text/* mime type.


More information about the freebsd-hackers mailing list