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

Re: svn commit: r14262 - trunk/subversion/mod_dav_svn

From: Branko Čibej <brane_at_xbc.nu>
Date: 2005-05-05 01:53:42 CEST

kfogel@collab.net wrote:

>Branko Čibej <brane@xbc.nu> writes:
>
>
>>>I would think "application/octet-stream" would be a lot safer when we
>>>don't know anything about the file. Does anyone know more about this?
>>>
>>>
>>When it sees a file that doesn't have the svn:mime-type property set,
>>Subversion assumes it is a text file. It would be slighly weird if
>>mod_dav_svn behaved differently.
>>
>>
>
>Would it?
>
>Subversion can make that assumption because it knows the domain of
>operations (diff, merge) to which the assumption will apply.
>
>But when we return a file in response to a generic DAV request, we
>have no idea what the user is going to do with it. In fact, it seems
>likely that someone using a generic DAV client to fetch a file will
>often not be obtaining a "text/plain" document. It's just as likely
>to be MSWord, Excel, whatever, and that some software consumers of the
>file would Do The Wrong Thing if they thought were plain text.
>
>
If it's really not a text file, Subversion will tag it as
application/octet-stream itself when you add the file to the repository.

(Well, we should really do the binary check every time we commit
changes, if svn:mime-type is not set. But that's a different issue.)

>Also, notice how the "text/plain" assumption is given lie in
>mod_dav_svn/repos.c, right below the code we're talking about:
>
> if (value)
> mimetype = value->data;
> else if ((! resource->info->repos->is_svn_client)
> && r->content_type)
> mimetype = r->content_type;
> else
> mimetype = "text/plain";
>
> serr = svn_mime_type_validate(mimetype, resource->pool);
> if (serr)
> {
> /* Probably serr->apr == SVN_ERR_BAD_MIME_TYPE, but
> there's no point even checking. No matter what the
> error is, we can't derive the mime type from the
> svn:mime-type property. So we resort to the infamous
> "mime type of last resort." */
> svn_error_clear(serr);
> mimetype = "application/octet-stream";
> }
>
>Kind of hard to square that last assignment with the final 'else'
>above it!
>
>
Not really. This will catch the case where the mime type was set either
in the prop or (I assume) by mod_mime, *but* the syntax of the value
wasn't valid. In that case generic binary is a better choice than either
generic text or (obviously) an invalid type. Note that
svn_mime_type_validate won't trigger for "text/plain", which we only set
explicitly if the svn:mime-type prop doesn't exist at all.

-- Brane

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu May 5 01:54:12 2005

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.