[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Is XML text?

From: Branko Čibej <brane_at_xbc.nu>
Date: 2004-05-16 21:27:20 CEST

Kalle Olavi Niemitalo wrote:

>Here is a similar patch that I've been using. The primary
>difference is that mine ignores parameters such as charset=UTF-8.
>Also, it treats plain application/xml as binary; perhaps I should
>change that.
>
>Index: validate.c
>===================================================================
>--- validate.c (revision 9614)
>+++ validate.c (working copy)
>@@ -65,8 +65,27 @@
> svn_boolean_t
> svn_mime_type_is_binary (const char *mime_type)
> {
>- return ((strncmp (mime_type, "text/", 5) != 0)
>- && (strcmp (mime_type, "image/x-xbitmap") != 0)
>- && (strcmp (mime_type, "image/x-xpixmap") != 0)
>- );
>+ /* To get "Content-Type: text/html; charset=UTF-8" from mod_dav_svn,
>+ the charset must be in the svn:mime-type property too. Ignore
>+ any such parameters here.
>
>
Ah, but you see, the property is called svn:mime-type, not
svn:content-type -- which means that if somebody sets the charset too,
they're violating the API. I think.

>+ RFC 2045 (5.1) and RFC 2616 (3.7) say that the type/subtype pair
>+ must be compared case-insensitively. RFC 2616 (2.2 and 14.17)
>+ prohibits comments in HTTP Content-Type even though RFC 2045
>+ (5.1) allows them in email. */
>+
>+ size_t len = strcspn (mime_type, " ;");
>+
>+ if (strncasecmp (mime_type, "text/", 5) == 0)
>+ return FALSE;
>+
>+ if (len == 15 && strncasecmp (mime_type, "image/x-xbitmap", len) == 0)
>+ return FALSE;
>+ if (len == 15 && strncasecmp (mime_type, "image/x-xpixmap", len) == 0)
>+ return FALSE;
>+
>+ if (len >= 4 && strncasecmp (mime_type + len - 4, "+xml", 4) == 0)
>+ return FALSE;
>
>
This will work *if* mime-type values only use ASCII chars. I expect they do.

By the way, your patch ignores the "*/xml*" pattern, which is fairly common.

-- Brane

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun May 16 21:29:09 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.