[2056] in Moira

home help back first fref pref prev next nref lref last post

users with high-bit characters in their names

daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Thu Feb 12 19:04:08 2004

Message-Id: <200402130004.i1D0442X023238@brad-majors.mit.edu>
To: moiradev@MIT.EDU
Date: Thu, 12 Feb 2004 19:04:04 -0500
From: Garry Zacheiss <zacheiss@MIT.EDU>

I got mail from the Data Warehouse team today about a user with accented
characters in their first and middle names that was showing up funny
looking when viewed in moira.  It turns out there was two problems:

- FixCase() would uppercase every character after a character with the
high bit set, since that was its default action; this caused corruption
of the names during the student/staff load, and also when the names were
displayed by clients.  I fixed this by adding code to FixCase() to not
uppercase the next character when the current character has the high bit
set.

- mr_trim_args() would punt on trimming white space off of strings if
any of the characters in them had the high bit set; this was a leftover
from GDSS signatures, but we don't have any fields of binary data in
moira anymore that we care about, so I just removed this code.

With the patches below, the staff load correctly loads names with high
bit characters, and one can view them without corruption of extra
whitespace padding.

Garry

Index: lib/fixname.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/lib/fixname.c,v
retrieving revision 1.15
diff -u -r1.15 fixname.c
--- lib/fixname.c	20 Dec 1998 21:23:18 -0000	1.15
+++ lib/fixname.c	12 Feb 2004 22:52:12 -0000
@@ -48,7 +48,7 @@
   strncpy(first, ifnm, FIRST_LEN);
 }
 
-void FixCase(char *p)
+void FixCase(unsigned char *p)
 {
   int up;	/* Should next letter be uppercase */
   int pos;	/* Position within word */
@@ -69,6 +69,8 @@
 	}
       else if (*p == '\'')	/* If ', next letter should be upper only */
 	up = (pos == 2);	/* if the ' is the 2nd char in the name */
+      else if (*p >= 0x80)      /* If the high bit is set, don't touch it. */
+	up = 0;
       else
 	up = 1;			/* If other punctuation (eg, -), upper */
     }
Index: server/mr_util.c
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/server/mr_util.c,v
retrieving revision 1.32
diff -u -r1.32 mr_util.c
--- server/mr_util.c	19 Oct 1998 20:18:58 -0000	1.32
+++ server/mr_util.c	12 Feb 2004 23:00:49 -0000
@@ -102,8 +102,7 @@
 
 
 /* mr_trim_args: passed an argument vector, it will trim any trailing
- * spaces on the args by writing a null into the string.  If an argument
- * appears to be binary instead of ASCII, it will not be trimmed.
+ * spaces on the args by writing a null into the string.
  */
 
 int mr_trim_args(int argc, char **argv)
@@ -115,16 +114,6 @@
     {
       for (lastch = p = (unsigned char *) *arg; *p; p++)
 	{
-	  /* If any byte in the string has the high bit set, assume
-	   * that it is binary and we do not want to trim it.
-	   * Setting p = lastch will cause us not to trim the string
-	   * when we break out of this inner loop.
-	   */
-	  if (*p >= 0x80)
-	    {
-	      p = lastch;
-	      break;
-	    }
 	  if (!isspace(*p))
 	    lastch = p;
 	}

home help back first fref pref prev next nref lref last post