You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Kalle Olavi Niemitalo <ko...@iki.fi> on 2004/08/05 17:36:23 UTC
Re: SVN Property 'character-set' or 'encoding' or something like
Branko Čibej <br...@xbc.nu> writes:
> Yes, and in the meantime I withdrew my objection, and there is now
> code in the 1.1 release candidate that takes this into account.
Sorry, I haven't been paying attention. It's r10126, isn't it?
The code seems wrong to me; it'll treat e.g. "image/x" as text.
Re: SVN Property 'character-set' or 'encoding' or something like
Posted by Branko Čibej <br...@xbc.nu>.
Greg Hudson wrote:
>On Fri, 2004-08-06 at 09:46, Branko ÄŒibej wrote:
>
>
>>- && (strncmp (mime_type, "image/x-xbitmap", len) != 0)
>>- && (strncmp (mime_type, "image/x-xpixmap", len) != 0)
>>+ && (len != 15 || strncmp (mime_type, "image/x-xbitmap", 15) != 0)
>>+ && (len != 15 || strncmp (mime_type, "image/x-xpixmap", 15) != 0)
>>
>>
>
>Isn't this what "strcmp" is for?
>
No it's not. "len" doesn't come from "strlen" but from "strcspn", and a
comment in the code explains why.
-- Brane
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: SVN Property 'character-set' or 'encoding' or something like
Posted by Greg Hudson <gh...@MIT.EDU>.
On Fri, 2004-08-06 at 09:46, Branko Čibej wrote:
> - && (strncmp (mime_type, "image/x-xbitmap", len) != 0)
> - && (strncmp (mime_type, "image/x-xpixmap", len) != 0)
> + && (len != 15 || strncmp (mime_type, "image/x-xbitmap", 15) != 0)
> + && (len != 15 || strncmp (mime_type, "image/x-xpixmap", 15) != 0)
Isn't this what "strcmp" is for?
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: SVN Property 'character-set' or 'encoding' or something like
Posted by Branko Čibej <br...@xbc.nu>.
Kalle Olavi Niemitalo wrote:
>Branko Čibej <br...@xbc.nu> writes:
>
>
>
>>Yes, and in the meantime I withdrew my objection, and there is now
>>code in the 1.1 release candidate that takes this into account.
>>
>>
>
>Sorry, I haven't been paying attention. It's r10126, isn't it?
>The code seems wrong to me; it'll treat e.g. "image/x" as text.
>
>
What? Oh, bother...
Index: validate.c
===================================================================
--- validate.c (revision 10504)
+++ validate.c (working copy)
@@ -70,7 +70,7 @@
/* See comment in svn_mime_type_validate() above. */
const apr_size_t len = strcspn (mime_type, "; ");
return ((strncmp (mime_type, "text/", 5) != 0)
- && (strncmp (mime_type, "image/x-xbitmap", len) != 0)
- && (strncmp (mime_type, "image/x-xpixmap", len) != 0)
+ && (len != 15 || strncmp (mime_type, "image/x-xbitmap", 15) != 0)
+ && (len != 15 || strncmp (mime_type, "image/x-xpixmap", 15) != 0)
);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: SVN Property 'character-set' or 'encoding' or something like
Posted by Kalle Olavi Niemitalo <ko...@iki.fi>.
Ben Reser <be...@reser.org> writes:
> On Thu, Aug 05, 2004 at 08:36:23PM +0300, Kalle Olavi Niemitalo wrote:
>> The code seems wrong to me; it'll treat e.g. "image/x" as text.
>
> No it won't. Just image/x-xbitmap and image/x-xpixmaps which are
> textual descriptions of an image. In fact they're basically C arrays.
Yes it does; I tested it. Here is the function from revision 10126 of
<http://svn.collab.net/repos/svn/trunk/subversion/libsvn_subr/validate.c>,
with my comments marked with "//":
svn_boolean_t
svn_mime_type_is_binary (const char *mime_type)
{
// Imagine mime_type is "image/x".
/* See comment in svn_mime_type_validate() above. */
const apr_size_t len = strcspn (mime_type, "; ");
// strcspn("image/x", "; ") returns 7; len=7.
return ((strncmp (mime_type, "text/", 5) != 0)
// strncmp("image/x", "text/", 5) returns -11, or something else negative.
&& (strncmp (mime_type, "image/x-xbitmap", len) != 0)
// strncmp("image/x", "image/x-xbitmap", 7) returns 0.
// svn_mime_type_is_binary("image/x") returns 0, which is wrong.
&& (strncmp (mime_type, "image/x-xpixmap", len) != 0)
);
}
Re: SVN Property 'character-set' or 'encoding' or something like
Posted by Ben Reser <be...@reser.org>.
On Thu, Aug 05, 2004 at 08:36:23PM +0300, Kalle Olavi Niemitalo wrote:
> Branko ??ibej <br...@xbc.nu> writes:
>
> > Yes, and in the meantime I withdrew my objection, and there is now
> > code in the 1.1 release candidate that takes this into account.
>
> Sorry, I haven't been paying attention. It's r10126, isn't it?
> The code seems wrong to me; it'll treat e.g. "image/x" as text.
No it won't. Just image/x-xbitmap and image/x-xpixmaps which are
textual descriptions of an image. In fact they're basically C arrays.
--
Ben Reser <be...@reser.org>
http://ben.reser.org
"Conscience is the inner voice which warns us somebody may be looking."
- H.L. Mencken
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org