Re: [LOW] STR #4072: Sanitising job name and title

Michael Sweet <[email protected]> Sun, 16 Sep 2012 16:20:48 -0700 (PDT)
Newsgroups gmane.comp.printing.cups.bugs
Message-ID <[email protected]>
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR Closed w/Resolution]

OK, one more try, attached.

RFC 5198 talks about limiting which control characters are allowed for
Network Unicode.  IPP Everywhere talks about limiting the control
characters to TAB for name and nameWithLanguage values.

Link: http://www.cups.org/str.php?L4072
Version: 1.5.2
Fix Version: 1.7-current (r10609)

_______________________________________________
cups-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/cups-bugs
str4072p2.patch (text/plain, 1.3 KB)
Index: scheduler/ipp.c
===================================================================
--- scheduler/ipp.c	(revision 10606)
+++ scheduler/ipp.c	(working copy)
@@ -11039,18 +11039,30 @@
           break;
         else if (*nameptr == 0x7f)
           break;
-        else if ((*nameptr & 0xe0) == 0xc0 &&
-                 (nameptr[1] & 0xc0) != 0x80)
-          break;
-        else if ((*nameptr & 0xf0) == 0xe0 &&
-                 ((nameptr[1] & 0xc0) != 0x80 ||
-                  (nameptr[2] & 0xc0) != 0x80))
-          break;
-        else if ((*nameptr & 0xf8) == 0xf0 &&
-                 ((nameptr[1] & 0xc0) != 0x80 ||
-                  (nameptr[2] & 0xc0) != 0x80 ||
-                  (nameptr[3] & 0xc0) != 0x80))
-          break;
+        else if ((*nameptr & 0xe0) == 0xc0)
+        {
+          if ((nameptr[1] & 0xc0) != 0x80)
+            break;
+
+          nameptr ++;
+        }
+        else if ((*nameptr & 0xf0) == 0xe0)
+        {
+          if ((nameptr[1] & 0xc0) != 0x80 ||
+              (nameptr[2] & 0xc0) != 0x80)
+	    break;
+
+	  nameptr += 2;
+	}
+        else if ((*nameptr & 0xf8) == 0xf0)
+        {
+          if ((nameptr[1] & 0xc0) != 0x80 ||
+	      (nameptr[2] & 0xc0) != 0x80 ||
+	      (nameptr[3] & 0xc0) != 0x80)
+	    break;
+
+	  nameptr += 3;
+	}
         else if (*nameptr & 0x80)
           break;
       }