You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by "Peter N. Lundblad" <pe...@famlundblad.se> on 2004/11/25 16:08:52 UTC
Re: svn commit: r12029 - trunk/subversion/libsvn_client
On Wed, 24 Nov 2004 kfogel@tigris.org wrote:
> Author: kfogel
> Date: Wed Nov 24 20:00:46 2004
> New Revision: 12029
>
> Modified:
> trunk/subversion/libsvn_client/prop_commands.c
> Log:
> Fix issue #1832: Don't use potentially locale-sensitive tests to
> determine if characters are in a specific subset of the ASCII subset
> of UTF8. Thanks to Joe Orton <jo...@light.plus.com> for analysis.
>
> * subversion/libsvn_client/prop_commands.c
> (is_valid_prop_name): Test numeric values of characters directly.
>
>
> Modified: trunk/subversion/libsvn_client/prop_commands.c
> Url: http://svn.collab.net/viewcvs/svn/trunk/subversion/libsvn_client/prop_commands.c?view=diff&rev=12029&p1=trunk/subversion/libsvn_client/prop_commands.c&r1=12028&p2=trunk/subversion/libsvn_client/prop_commands.c&r2=12029
> ==============================================================================
> --- trunk/subversion/libsvn_client/prop_commands.c (original)
> +++ trunk/subversion/libsvn_client/prop_commands.c Wed Nov 24 20:00:46 2004
> @@ -46,14 +46,27 @@
> {
> const char *p = name;
>
> - /* Each byte of a UTF8-encoded non-ASCII character has its high bit set and
> - * so will be rejected by this function. */
> - if (! isalpha (*p) && ! strchr ("_:", *p))
> + /* The characters we allow use identical representations in UTF8
> + and ASCII, so we can just test for the appropriate ASCII codes.
> + But we can't use standard C character notation ('A', 'B', etc)
> + because there's no guarantee that this C environment is using
> + ASCII. So we hardcode the numbers below. */
> +
> + if (! ((*p >= 65 && *p <= 90) /* ASCII 'A' to 'Z' */
> + || (*p >= 97 && *p <= 122) /* ASCII 'a' to 'z' */
> + || (*p == 95) /* ASCII '_' */
> + || (*p == 58))) /* ASCII ':' */
> return FALSE;
> p++;
> for (; *p; p++)
> {
> - if (! isalnum (*p) && ! strchr (".-_:", *p))
> + if (! ((*p >= 65 && *p <= 90) /* ASCII 'A' to 'Z' */
> + || (*p >= 97 && *p <= 122) /* ASCII 'a' to 'z' */
> + || (*p >= 48 && *p <= 57) /* ASCII '0' to '9' */
> + || (*p == 95) /* ASCII '_' */
> + || (*p == 58) /* ASCII ':' */
> + || (*p == 46) /* ASCII '.' */
> + || (*p == 45))) /* ASCII '-' */
We have to decide, once and for all, if we support systems with an
execution character set that isn't ASCII-based (i.e. ASCII is a subset).
As brane points out, we have other places that use character constants.
Unless you are going to fix all these, it makes no sense to say 65 instead
of 'A'. If we want to support EBCDIC and such, we should define symbolic
constants instead of spreading these numbers all over the code.
An aside: why limit property names to ASCII? Is there a reason other than
"it is simple for now"? Else, I'll file an issue about supporting the
whole Name production in XML 1.1. (Or do we have to stick to XML 1.0?)
//Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: r12029 - trunk/subversion/libsvn_client
Posted by David James <ja...@gmail.com>.
On Thu, 25 Nov 2004 17:08:52 +0100 (CET), Peter N. Lundblad
<pe...@famlundblad.se> wrote:
> On Wed, 24 Nov 2004 kfogel@tigris.org wrote:
> > Author: kfogel
> > Date: Wed Nov 24 20:00:46 2004
> > New Revision: 12029
> >
> > Modified:
> > trunk/subversion/libsvn_client/prop_commands.c
> > Log:
> > Fix issue #1832: Don't use potentially locale-sensitive tests to
> > determine if characters are in a specific subset of the ASCII subset
> > of UTF8. Thanks to Joe Orton <jo...@light.plus.com> for analysis.
> >
> > * subversion/libsvn_client/prop_commands.c
> > (is_valid_prop_name): Test numeric values of characters directly.
> >
> >
> > Modified: trunk/subversion/libsvn_client/prop_commands.c
> > Url: http://svn.collab.net/viewcvs/svn/trunk/subversion/libsvn_client/prop_commands.c?view=diff&rev=12029&p1=trunk/subversion/libsvn_client/prop_commands.c&r1=12028&p2=trunk/subversion/libsvn_client/prop_commands.c&r2=12029
> > ==============================================================================
> > --- trunk/subversion/libsvn_client/prop_commands.c (original)
> > +++ trunk/subversion/libsvn_client/prop_commands.c Wed Nov 24 20:00:46 2004
> > @@ -46,14 +46,27 @@
> > {
> > const char *p = name;
> >
> > - /* Each byte of a UTF8-encoded non-ASCII character has its high bit set and
> > - * so will be rejected by this function. */
> > - if (! isalpha (*p) && ! strchr ("_:", *p))
> > + /* The characters we allow use identical representations in UTF8
> > + and ASCII, so we can just test for the appropriate ASCII codes.
> > + But we can't use standard C character notation ('A', 'B', etc)
> > + because there's no guarantee that this C environment is using
> > + ASCII. So we hardcode the numbers below. */
> > +
> > + if (! ((*p >= 65 && *p <= 90) /* ASCII 'A' to 'Z' */
> > + || (*p >= 97 && *p <= 122) /* ASCII 'a' to 'z' */
> > + || (*p == 95) /* ASCII '_' */
> > + || (*p == 58))) /* ASCII ':' */
> > return FALSE;
> > p++;
> > for (; *p; p++)
> > {
> > - if (! isalnum (*p) && ! strchr (".-_:", *p))
> > + if (! ((*p >= 65 && *p <= 90) /* ASCII 'A' to 'Z' */
> > + || (*p >= 97 && *p <= 122) /* ASCII 'a' to 'z' */
> > + || (*p >= 48 && *p <= 57) /* ASCII '0' to '9' */
> > + || (*p == 95) /* ASCII '_' */
> > + || (*p == 58) /* ASCII ':' */
> > + || (*p == 46) /* ASCII '.' */
> > + || (*p == 45))) /* ASCII '-' */
>
> We have to decide, once and for all, if we support systems with an
> execution character set that isn't ASCII-based (i.e. ASCII is a subset).
> As brane points out, we have other places that use character constants.
> Unless you are going to fix all these, it makes no sense to say 65 instead
> of 'A'. If we want to support EBCDIC and such, we should define symbolic
> constants instead of spreading these numbers all over the code.
Perhaps we should create ascii_isalpha and ascii_isnum functions?
This'll save us from spreading these numbers all over the code.
Dave
--
http://www.cs.toronto.edu/~james
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: r12029 - trunk/subversion/libsvn_client
Posted by Julian Foad <ju...@btopenworld.com>.
kfogel@collab.net wrote:
> "Peter N. Lundblad" <pe...@famlundblad.se> writes:
>>An aside: why limit property names to ASCII? Is there a reason other than
>>"it is simple for now"? Else, I'll file an issue about supporting the
>>whole Name production in XML 1.1. (Or do we have to stick to XML 1.0?)
>
> Yeah, I don't know why we're limiting property names to ASCII, except
> perhaps that it's easy to implement [...]
It's because, given that we were not able to define and implement the One True
Solution, it is better to be very restrictive at first (and have the option of
relaxing the rules later in a compatible manner) than to be unrestrictive and
let people end up with repositories containing names that don't work with
certain RA methods, etc.
The XML "Name" production does seem to be a reasonable definition that we might
want to choose for our property names. +1 to documenting and implementing it.
(I don't know the difference between XML 1.0 vs. 1.1, but the question of what
set of names we allow for our properties need not necessarily be related to the
set of Names that a particular version of XML defines. It just might be wise
to restrict ourselves to a (proper or improper) subset of XML Names to avoid
implementation difficulties - having to escape or encode the names, etc.)
- Julian
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: r12029 - trunk/subversion/libsvn_client
Posted by kf...@collab.net.
"Peter N. Lundblad" <pe...@famlundblad.se> writes:
> We have to decide, once and for all, if we support systems with an
> execution character set that isn't ASCII-based (i.e. ASCII is a subset).
> As brane points out, we have other places that use character constants.
> Unless you are going to fix all these, it makes no sense to say 65 instead
> of 'A'. If we want to support EBCDIC and such, we should define symbolic
> constants instead of spreading these numbers all over the code.
Obviously, if these numbers ever start appearing elsewhere, we'll
abstract things out. When they're only in one function, there's no
point creating named constants, it would only obscure.
Re the larger question, that is essentially what I was opening in the
thread entitled "using isalpha/isalnum in locale-independent code", so
maybe follow up there?
I realize there are two unrelated questions going on: the question of
locale, and the question of execution character set (i.e., ASCII vs
EBCDIC). If we decide to support ASCII only, then r12029 can be
tweaked to use character constants instead of numbers, but it can't go
back to using isalpha()/isalnum().
> An aside: why limit property names to ASCII? Is there a reason other than
> "it is simple for now"? Else, I'll file an issue about supporting the
> whole Name production in XML 1.1. (Or do we have to stick to XML 1.0?)
Yeah, I don't know why we're limiting property names to ASCII, except
perhaps that it's easy to implement (basically I was just trying to
make the function do what it claimed to do -- not trying to change the
claim itself :-) ). +1 on the issue, though realistically I wonder
when we'd get around to doing anything about it, as it's probably not
a showstopper for any users.
-K
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org