summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Untz <vuntz@suse.com>2012-12-10 10:49:23 +0100
committerVincent Untz <vuntz@suse.com>2012-12-10 10:49:23 +0100
commit810b0495d1e8870d03fc45a078bd14872f3d6b7c (patch)
tree686784640a06485fec9a91364241f653f3f5b2d5
parentf00aee0b43c31e94087668b23b72e873c660de5e (diff)
Document our source for validating printer names
Since the change that got reverted was justified by some cups documentation, it's important to clearly document where the current validation scheme comes from (lpadmin man page and cups source). Also, fix the size check: the cups source code limits this to 127.
-rw-r--r--src/cups.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cups.c b/src/cups.c
index 09f0e7b..92425eb 100644
--- a/src/cups.c
+++ b/src/cups.c
@@ -327,6 +327,12 @@ _cph_cups_is_printer_name_valid_internal (const char *name)
int i;
int len;
+ /* Quoting the lpadmin man page:
+ * CUPS allows printer names to contain any printable character
+ * except SPACE, TAB, "/", or "#".
+ * On top of that, validate_name() in lpadmin.c (from cups) checks that
+ * the string is 127 characters long, or shorter. */
+
/* no empty string */
if (!name || name[0] == '\0')
return FALSE;
@@ -334,7 +340,7 @@ _cph_cups_is_printer_name_valid_internal (const char *name)
len = strlen (name);
/* no string that is too long; see comment at the beginning of the
* validation code block */
- if (len > CPH_STR_MAXLEN)
+ if (len > 127)
return FALSE;
/* only printable characters, no space, no /, no # */