From 2da2477dac86b7b4e87ed025ae96940c44405026 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Wed, 31 Jan 2018 14:23:05 -0500 Subject: [PATCH] Use ippValidateAttribute to validate attributes in ipptool. Fix localization typo. --- cups/ipp.c | 227 ++++------------ locale/cups.pot | 175 ++++++------- locale/cups.strings | 5 +- locale/cups_ca.po | 18 +- locale/cups_cs.po | 10 +- locale/cups_es.po | 18 +- locale/cups_fr.po | 10 +- locale/cups_it.po | 18 +- locale/cups_ja.po | 18 +- locale/cups_pt_BR.po | 18 +- locale/cups_ru.po | 18 +- locale/cups_zh_CN.po | 18 +- test/ipptool.c | 606 +------------------------------------------ 13 files changed, 209 insertions(+), 950 deletions(-) diff --git a/cups/ipp.c b/cups/ipp.c index 58f120c0f..ec76bec64 100644 --- a/cups/ipp.c +++ b/cups/ipp.c @@ -4802,21 +4802,6 @@ ippValidateAttribute( ipp_attribute_t *colattr; /* Collection attribute */ regex_t re; /* Regular expression */ ipp_uchar_t *date; /* Current date value */ - static const char * const uri_status_strings[] = - { /* URI status strings */ - "URI too large", - "Bad arguments to function", - "Bad resource in URI", - "Bad port number in URI", - "Bad hostname/address in URI", - "Bad username in URI", - "Bad scheme in URI", - "Bad/empty URI", - "OK", - "Missing scheme in URI", - "Unknown scheme in URI", - "Missing resource in URI" - }; /* @@ -4836,18 +4821,13 @@ ippValidateAttribute( if (*ptr || ptr == attr->name) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad attribute name - invalid character " - "(RFC 8011 section 5.1.4)."), attr->name); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad attribute name - invalid character (RFC 8011 section 5.1.4)."), attr->name); return (0); } if ((ptr - attr->name) > 255) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad attribute name - bad length %d " - "(RFC 8011 section 5.1.4)."), attr->name, - (int)(ptr - attr->name)); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad attribute name - bad length %d (RFC 8011 section 5.1.4)."), attr->name, (int)(ptr - attr->name)); return (0); } @@ -4862,10 +4842,7 @@ ippValidateAttribute( if (attr->values[i].boolean != 0 && attr->values[i].boolean != 1) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad boolen value %d " - "(RFC 8011 section 5.1.21)."), attr->name, - attr->values[i].boolean); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad boolean value %d (RFC 8011 section 5.1.21)."), attr->name, attr->values[i].boolean); return (0); } } @@ -4876,10 +4853,7 @@ ippValidateAttribute( { if (attr->values[i].integer < 1) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad enum value %d - out of range " - "(RFC 8011 section 5.1.5)."), attr->name, - attr->values[i].integer); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad enum value %d - out of range (RFC 8011 section 5.1.5)."), attr->name, attr->values[i].integer); return (0); } } @@ -4890,10 +4864,7 @@ ippValidateAttribute( { if (attr->values[i].unknown.length > IPP_MAX_OCTETSTRING) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad octetString value - bad length %d " - "(RFC 8011 section 5.1.20)."), attr->name, - attr->values[i].unknown.length); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad octetString value - bad length %d (RFC 8011 section 5.1.20)."), attr->name, attr->values[i].unknown.length); return (0); } } @@ -4906,73 +4877,55 @@ ippValidateAttribute( if (date[2] < 1 || date[2] > 12) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad dateTime month %u " - "(RFC 8011 section 5.1.15)."), attr->name, date[2]); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime month %u (RFC 8011 section 5.1.15)."), attr->name, date[2]); return (0); } if (date[3] < 1 || date[3] > 31) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad dateTime day %u " - "(RFC 8011 section 5.1.15)."), attr->name, date[3]); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime day %u (RFC 8011 section 5.1.15)."), attr->name, date[3]); return (0); } if (date[4] > 23) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad dateTime hours %u " - "(RFC 8011 section 5.1.15)."), attr->name, date[4]); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime hours %u (RFC 8011 section 5.1.15)."), attr->name, date[4]); return (0); } if (date[5] > 59) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad dateTime minutes %u " - "(RFC 8011 section 5.1.15)."), attr->name, date[5]); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime minutes %u (RFC 8011 section 5.1.15)."), attr->name, date[5]); return (0); } if (date[6] > 60) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad dateTime seconds %u " - "(RFC 8011 section 5.1.15)."), attr->name, date[6]); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime seconds %u (RFC 8011 section 5.1.15)."), attr->name, date[6]); return (0); } if (date[7] > 9) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad dateTime deciseconds %u " - "(RFC 8011 section 5.1.15)."), attr->name, date[7]); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime deciseconds %u (RFC 8011 section 5.1.15)."), attr->name, date[7]); return (0); } if (date[8] != '-' && date[8] != '+') { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad dateTime UTC sign '%c' " - "(RFC 8011 section 5.1.15)."), attr->name, date[8]); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime UTC sign '%c' (RFC 8011 section 5.1.15)."), attr->name, date[8]); return (0); } if (date[9] > 11) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad dateTime UTC hours %u " - "(RFC 8011 section 5.1.15)."), attr->name, date[9]); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime UTC hours %u (RFC 8011 section 5.1.15)."), attr->name, date[9]); return (0); } if (date[10] > 59) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad dateTime UTC minutes %u " - "(RFC 8011 section 5.1.15)."), attr->name, date[10]); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad dateTime UTC minutes %u (RFC 8011 section 5.1.15)."), attr->name, date[10]); return (0); } } @@ -4983,46 +4936,19 @@ ippValidateAttribute( { if (attr->values[i].resolution.xres <= 0) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad resolution value %dx%d%s - cross " - "feed resolution must be positive " - "(RFC 8011 section 5.1.16)."), attr->name, - attr->values[i].resolution.xres, - attr->values[i].resolution.yres, - attr->values[i].resolution.units == - IPP_RES_PER_INCH ? "dpi" : - attr->values[i].resolution.units == - IPP_RES_PER_CM ? "dpcm" : "unknown"); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad resolution value %dx%d%s - cross feed resolution must be positive (RFC 8011 section 5.1.16)."), attr->name, attr->values[i].resolution.xres, attr->values[i].resolution.yres, attr->values[i].resolution.units == IPP_RES_PER_INCH ? "dpi" : attr->values[i].resolution.units == IPP_RES_PER_CM ? "dpcm" : "unknown"); return (0); } if (attr->values[i].resolution.yres <= 0) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad resolution value %dx%d%s - feed " - "resolution must be positive " - "(RFC 8011 section 5.1.16)."), attr->name, - attr->values[i].resolution.xres, - attr->values[i].resolution.yres, - attr->values[i].resolution.units == - IPP_RES_PER_INCH ? "dpi" : - attr->values[i].resolution.units == - IPP_RES_PER_CM ? "dpcm" : "unknown"); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad resolution value %dx%d%s - feed resolution must be positive (RFC 8011 section 5.1.16)."), attr->name, attr->values[i].resolution.xres, attr->values[i].resolution.yres, attr->values[i].resolution.units == IPP_RES_PER_INCH ? "dpi" : attr->values[i].resolution.units == IPP_RES_PER_CM ? "dpcm" : "unknown"); return (0); } - if (attr->values[i].resolution.units != IPP_RES_PER_INCH && - attr->values[i].resolution.units != IPP_RES_PER_CM) + if (attr->values[i].resolution.units != IPP_RES_PER_INCH && attr->values[i].resolution.units != IPP_RES_PER_CM) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad resolution value %dx%d%s - bad " - "units value (RFC 8011 section 5.1.16)."), - attr->name, attr->values[i].resolution.xres, - attr->values[i].resolution.yres, - attr->values[i].resolution.units == - IPP_RES_PER_INCH ? "dpi" : - attr->values[i].resolution.units == - IPP_RES_PER_CM ? "dpcm" : "unknown"); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad resolution value %dx%d%s - bad units value (RFC 8011 section 5.1.16)."), attr->name, attr->values[i].resolution.xres, attr->values[i].resolution.yres, attr->values[i].resolution.units == IPP_RES_PER_INCH ? "dpi" : attr->values[i].resolution.units == IPP_RES_PER_CM ? "dpcm" : "unknown"); return (0); } } @@ -5033,11 +4959,7 @@ ippValidateAttribute( { if (attr->values[i].range.lower > attr->values[i].range.upper) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad rangeOfInteger value %d-%d - lower " - "greater than upper (RFC 8011 section 5.1.14)."), - attr->name, attr->values[i].range.lower, - attr->values[i].range.upper); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad rangeOfInteger value %d-%d - lower greater than upper (RFC 8011 section 5.1.14)."), attr->name, attr->values[i].range.lower, attr->values[i].range.upper); return (0); } } @@ -5095,20 +5017,13 @@ ippValidateAttribute( if (*ptr) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad text value \"%s\" - bad UTF-8 " - "sequence (RFC 8011 section 5.1.2)."), attr->name, - attr->values[i].string.text); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad text value \"%s\" - bad UTF-8 sequence (RFC 8011 section 5.1.2)."), attr->name, attr->values[i].string.text); return (0); } if ((ptr - attr->values[i].string.text) > (IPP_MAX_TEXT - 1)) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad text value \"%s\" - bad length %d " - "(RFC 8011 section 5.1.2)."), attr->name, - attr->values[i].string.text, - (int)(ptr - attr->values[i].string.text)); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad text value \"%s\" - bad length %d (RFC 8011 section 5.1.2)."), attr->name, attr->values[i].string.text, (int)(ptr - attr->values[i].string.text)); return (0); } } @@ -5153,20 +5068,13 @@ ippValidateAttribute( if (*ptr) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad name value \"%s\" - bad UTF-8 " - "sequence (RFC 8011 section 5.1.3)."), attr->name, - attr->values[i].string.text); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad name value \"%s\" - bad UTF-8 sequence (RFC 8011 section 5.1.3)."), attr->name, attr->values[i].string.text); return (0); } if ((ptr - attr->values[i].string.text) > (IPP_MAX_NAME - 1)) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad name value \"%s\" - bad length %d " - "(RFC 8011 section 5.1.3)."), attr->name, - attr->values[i].string.text, - (int)(ptr - attr->values[i].string.text)); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad name value \"%s\" - bad length %d (RFC 8011 section 5.1.3)."), attr->name, attr->values[i].string.text, (int)(ptr - attr->values[i].string.text)); return (0); } } @@ -5176,26 +5084,21 @@ ippValidateAttribute( for (i = 0; i < attr->num_values; i ++) { for (ptr = attr->values[i].string.text; *ptr; ptr ++) + { if (!isalnum(*ptr & 255) && *ptr != '-' && *ptr != '.' && *ptr != '_') break; + } if (*ptr || ptr == attr->values[i].string.text) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad keyword value \"%s\" - invalid " - "character (RFC 8011 section 5.1.4)."), - attr->name, attr->values[i].string.text); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad keyword value \"%s\" - invalid character (RFC 8011 section 5.1.4)."), attr->name, attr->values[i].string.text); return (0); } if ((ptr - attr->values[i].string.text) > (IPP_MAX_KEYWORD - 1)) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad keyword value \"%s\" - bad " - "length %d (RFC 8011 section 5.1.4)."), - attr->name, attr->values[i].string.text, - (int)(ptr - attr->values[i].string.text)); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad keyword value \"%s\" - bad length %d (RFC 8011 section 5.1.4)."), attr->name, attr->values[i].string.text, (int)(ptr - attr->values[i].string.text)); return (0); } } @@ -5204,31 +5107,17 @@ ippValidateAttribute( case IPP_TAG_URI : for (i = 0; i < attr->num_values; i ++) { - uri_status = httpSeparateURI(HTTP_URI_CODING_ALL, - attr->values[i].string.text, - scheme, sizeof(scheme), - userpass, sizeof(userpass), - hostname, sizeof(hostname), - &port, resource, sizeof(resource)); + uri_status = httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[i].string.text, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, resource, sizeof(resource)); if (uri_status < HTTP_URI_STATUS_OK) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad URI value \"%s\" - %s " - "(RFC 8011 section 5.1.6)."), attr->name, - attr->values[i].string.text, - uri_status_strings[uri_status - - HTTP_URI_STATUS_OVERFLOW]); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad URI value \"%s\" - %s (RFC 8011 section 5.1.6)."), attr->name, attr->values[i].string.text, httpURIStatusString(uri_status)); return (0); } if (strlen(attr->values[i].string.text) > (IPP_MAX_URI - 1)) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad URI value \"%s\" - bad length %d " - "(RFC 8011 section 5.1.6)."), attr->name, - attr->values[i].string.text, - (int)strlen(attr->values[i].string.text)); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad URI value \"%s\" - bad length %d (RFC 8011 section 5.1.6)."), attr->name, attr->values[i].string.text, (int)strlen(attr->values[i].string.text)); } } break; @@ -5240,27 +5129,22 @@ ippValidateAttribute( if (islower(*ptr & 255)) { for (ptr ++; *ptr; ptr ++) + { if (!islower(*ptr & 255) && !isdigit(*ptr & 255) && *ptr != '+' && *ptr != '-' && *ptr != '.') break; + } } if (*ptr || ptr == attr->values[i].string.text) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad uriScheme value \"%s\" - bad " - "characters (RFC 8011 section 5.1.7)."), - attr->name, attr->values[i].string.text); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad uriScheme value \"%s\" - bad characters (RFC 8011 section 5.1.7)."), attr->name, attr->values[i].string.text); return (0); } if ((ptr - attr->values[i].string.text) > (IPP_MAX_URISCHEME - 1)) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad uriScheme value \"%s\" - bad " - "length %d (RFC 8011 section 5.1.7)."), - attr->name, attr->values[i].string.text, - (int)(ptr - attr->values[i].string.text)); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad uriScheme value \"%s\" - bad length %d (RFC 8011 section 5.1.7)."), attr->name, attr->values[i].string.text, (int)(ptr - attr->values[i].string.text)); return (0); } } @@ -5270,26 +5154,21 @@ ippValidateAttribute( for (i = 0; i < attr->num_values; i ++) { for (ptr = attr->values[i].string.text; *ptr; ptr ++) + { if (!isprint(*ptr & 255) || isupper(*ptr & 255) || isspace(*ptr & 255)) break; + } if (*ptr || ptr == attr->values[i].string.text) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad charset value \"%s\" - bad " - "characters (RFC 8011 section 5.1.8)."), - attr->name, attr->values[i].string.text); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad charset value \"%s\" - bad characters (RFC 8011 section 5.1.8)."), attr->name, attr->values[i].string.text); return (0); } if ((ptr - attr->values[i].string.text) > (IPP_MAX_CHARSET - 1)) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad charset value \"%s\" - bad " - "length %d (RFC 8011 section 5.1.8)."), - attr->name, attr->values[i].string.text, - (int)(ptr - attr->values[i].string.text)); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad charset value \"%s\" - bad length %d (RFC 8011 section 5.1.8)."), attr->name, attr->values[i].string.text, (int)(ptr - attr->values[i].string.text)); return (0); } } @@ -5321,9 +5200,7 @@ ippValidateAttribute( char temp[256]; /* Temporary error string */ regerror(i, &re, temp, sizeof(temp)); - ipp_set_error(IPP_STATUS_ERROR_INTERNAL, - _("Unable to compile naturalLanguage regular " - "expression: %s."), temp); + ipp_set_error(IPP_STATUS_ERROR_INTERNAL, _("Unable to compile naturalLanguage regular expression: %s."), temp); return (0); } @@ -5331,21 +5208,14 @@ ippValidateAttribute( { if (regexec(&re, attr->values[i].string.text, 0, NULL, 0)) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad naturalLanguage value \"%s\" - bad " - "characters (RFC 8011 section 5.1.9)."), - attr->name, attr->values[i].string.text); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad naturalLanguage value \"%s\" - bad characters (RFC 8011 section 5.1.9)."), attr->name, attr->values[i].string.text); regfree(&re); return (0); } if (strlen(attr->values[i].string.text) > (IPP_MAX_LANGUAGE - 1)) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad naturalLanguage value \"%s\" - bad " - "length %d (RFC 8011 section 5.1.9)."), - attr->name, attr->values[i].string.text, - (int)strlen(attr->values[i].string.text)); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad naturalLanguage value \"%s\" - bad length %d (RFC 8011 section 5.1.9)."), attr->name, attr->values[i].string.text, (int)strlen(attr->values[i].string.text)); regfree(&re); return (0); } @@ -5375,9 +5245,7 @@ ippValidateAttribute( char temp[256]; /* Temporary error string */ regerror(i, &re, temp, sizeof(temp)); - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("Unable to compile mimeMediaType regular " - "expression: %s."), temp); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("Unable to compile mimeMediaType regular expression: %s."), temp); return (0); } @@ -5385,21 +5253,14 @@ ippValidateAttribute( { if (regexec(&re, attr->values[i].string.text, 0, NULL, 0)) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad mimeMediaType value \"%s\" - bad " - "characters (RFC 8011 section 5.1.10)."), - attr->name, attr->values[i].string.text); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad mimeMediaType value \"%s\" - bad characters (RFC 8011 section 5.1.10)."), attr->name, attr->values[i].string.text); regfree(&re); return (0); } if (strlen(attr->values[i].string.text) > (IPP_MAX_MIMETYPE - 1)) { - ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, - _("\"%s\": Bad mimeMediaType value \"%s\" - bad " - "length %d (RFC 8011 section 5.1.10)."), - attr->name, attr->values[i].string.text, - (int)strlen(attr->values[i].string.text)); + ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad mimeMediaType value \"%s\" - bad length %d (RFC 8011 section 5.1.10)."), attr->name, attr->values[i].string.text, (int)strlen(attr->values[i].string.text)); regfree(&re); return (0); } diff --git a/locale/cups.pot b/locale/cups.pot index 395438b85..26fb46585 100644 --- a/locale/cups.pot +++ b/locale/cups.pot @@ -28,7 +28,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 2.3b2\n" "Report-Msgid-Bugs-To: https://github.com/apple/cups/issues\n" -"POT-Creation-Date: 2018-01-18 13:08-0500\n" +"POT-Creation-Date: 2018-01-31 14:22-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1018,7 +1018,7 @@ msgstr "" msgid " --false Always false." msgstr "" -#: test/ipptool.c:5227 +#: test/ipptool.c:4216 msgid " --help Show help." msgstr "" @@ -1030,7 +1030,7 @@ msgstr "" msgid " --host regex Match hostname to regular expression." msgstr "" -#: test/ipptool.c:5228 +#: test/ipptool.c:4217 msgid " --ippserver filename Produce ippserver attribute file." msgstr "" @@ -1082,7 +1082,7 @@ msgstr "" msgid " --remote True if service is remote." msgstr "" -#: test/ipptool.c:5229 +#: test/ipptool.c:4218 msgid "" " --stop-after-include-error\n" " Stop tests after a failed INCLUDE." @@ -1108,19 +1108,19 @@ msgstr "" msgid " --version Show program version." msgstr "" -#: test/ipptool.c:5231 +#: test/ipptool.c:4220 msgid " --version Show version." msgstr "" -#: test/ippfind.c:2758 test/ipptool.c:5232 +#: test/ippfind.c:2758 test/ipptool.c:4221 msgid " -4 Connect using IPv4." msgstr "" -#: test/ippfind.c:2759 test/ipptool.c:5233 +#: test/ippfind.c:2759 test/ipptool.c:4222 msgid " -6 Connect using IPv6." msgstr "" -#: test/ipptool.c:5234 +#: test/ipptool.c:4223 msgid " -C Send requests using chunking (default)." msgstr "" @@ -1136,7 +1136,7 @@ msgstr "" msgid " -E Encrypt the connection." msgstr "" -#: test/ipptool.c:5236 +#: test/ipptool.c:4225 msgid " -E Test with encryption using HTTP Upgrade to TLS." msgstr "" @@ -1148,7 +1148,7 @@ msgstr "" msgid " -H samba-server Use the named SAMBA server." msgstr "" -#: test/ipptool.c:5237 +#: test/ipptool.c:4226 msgid " -I Ignore errors." msgstr "" @@ -1160,11 +1160,11 @@ msgstr "" msgid " -I {filename,filters,none,profiles}" msgstr "" -#: test/ipptool.c:5238 +#: test/ipptool.c:4227 msgid " -L Send requests using content-length." msgstr "" -#: test/ipptool.c:5239 +#: test/ipptool.c:4228 msgid " -P filename.plist Produce XML plist to a file and test report to standard output." msgstr "" @@ -1180,7 +1180,7 @@ msgstr "" msgid " -R root-directory Set alternate root." msgstr "" -#: test/ipptool.c:5240 +#: test/ipptool.c:4229 msgid " -S Test with encryption using HTTPS." msgstr "" @@ -1188,7 +1188,7 @@ msgstr "" msgid " -T seconds Set the browse timeout in seconds." msgstr "" -#: test/ipptool.c:5241 +#: test/ipptool.c:4230 msgid " -T seconds Set the receive/send timeout in seconds." msgstr "" @@ -1196,7 +1196,7 @@ msgstr "" msgid " -U username Specify username." msgstr "" -#: test/ippfind.c:2762 test/ipptool.c:5242 +#: test/ippfind.c:2762 test/ipptool.c:4231 msgid " -V version Set default IPP version." msgstr "" @@ -1204,7 +1204,7 @@ msgstr "" msgid " -W {all,none,constraints,defaults,duplex,filters,profiles,sizes,translations}" msgstr "" -#: test/ipptool.c:5243 +#: test/ipptool.c:4232 msgid " -X Produce XML plist instead of plain text." msgstr "" @@ -1212,7 +1212,7 @@ msgstr "" msgid " -a Export all printers." msgstr "" -#: test/ipptool.c:5244 +#: test/ipptool.c:4233 msgid " -c Produce CSV output." msgstr "" @@ -1228,7 +1228,7 @@ msgstr "" msgid " -c cupsd.conf Set cupsd.conf file to use." msgstr "" -#: test/ipptool.c:5245 +#: test/ipptool.c:4234 msgid " -d name=value Set named variable to value." msgstr "" @@ -1252,7 +1252,7 @@ msgstr "" msgid " -f Run in the foreground." msgstr "" -#: test/ipptool.c:5246 +#: test/ipptool.c:4235 msgid " -f filename Set default request filename." msgstr "" @@ -1260,7 +1260,7 @@ msgstr "" msgid " -h Show this usage message." msgstr "" -#: test/ipptool.c:5247 +#: test/ipptool.c:4236 msgid " -h Validate HTTP response headers." msgstr "" @@ -1276,7 +1276,7 @@ msgstr "" msgid " -i mime/type Set input MIME type (otherwise auto-typed)." msgstr "" -#: test/ipptool.c:5248 +#: test/ipptool.c:4237 msgid " -i seconds Repeat the last file with the given time interval." msgstr "" @@ -1288,7 +1288,7 @@ msgstr "" msgid " -l List attributes." msgstr "" -#: test/ipptool.c:5249 +#: test/ipptool.c:4238 msgid " -l Produce plain text output." msgstr "" @@ -1312,7 +1312,7 @@ msgstr "" msgid " -n copies Set number of copies." msgstr "" -#: test/ipptool.c:5250 +#: test/ipptool.c:4239 msgid " -n count Repeat the last file the given number of times." msgstr "" @@ -1344,7 +1344,7 @@ msgstr "" msgid " -q Quietly report match via exit code." msgstr "" -#: systemv/cupstestppd.c:3862 test/ipptool.c:5251 +#: systemv/cupstestppd.c:3862 test/ipptool.c:4240 msgid " -q Run silently." msgstr "" @@ -1364,7 +1364,7 @@ msgstr "" msgid " -s cups-files.conf Set cups-files.conf file to use." msgstr "" -#: test/ipptool.c:5252 +#: test/ipptool.c:4241 msgid " -t Produce a test report." msgstr "" @@ -1392,7 +1392,7 @@ msgstr "" msgid " -u regex Match URI to regular expression." msgstr "" -#: systemv/cupsaddsmb.c:279 systemv/cupstestppd.c:3864 test/ipptool.c:5253 +#: systemv/cupsaddsmb.c:279 systemv/cupstestppd.c:3864 test/ipptool.c:4242 #: ppdc/ppdc.cxx:441 ppdc/ppdpo.cxx:248 msgid " -v Be verbose." msgstr "" @@ -1559,172 +1559,172 @@ msgstr "" msgid " PASS" msgstr "" -#: cups/ipp.c:5217 +#: cups/ipp.c:5114 #, c-format msgid "\"%s\": Bad URI value \"%s\" - %s (RFC 8011 section 5.1.6)." msgstr "" -#: cups/ipp.c:5228 +#: cups/ipp.c:5120 #, c-format msgid "\"%s\": Bad URI value \"%s\" - bad length %d (RFC 8011 section 5.1.6)." msgstr "" -#: cups/ipp.c:4848 +#: cups/ipp.c:4830 #, c-format msgid "\"%s\": Bad attribute name - bad length %d (RFC 8011 section 5.1.4)." msgstr "" -#: cups/ipp.c:4840 +#: cups/ipp.c:4824 #, c-format msgid "\"%s\": Bad attribute name - invalid character (RFC 8011 section 5.1.4)." msgstr "" -#: cups/ipp.c:4866 +#: cups/ipp.c:4845 #, c-format -msgid "\"%s\": Bad boolen value %d (RFC 8011 section 5.1.21)." +msgid "\"%s\": Bad boolean value %d (RFC 8011 section 5.1.21)." msgstr "" -#: cups/ipp.c:5280 +#: cups/ipp.c:5165 #, c-format msgid "\"%s\": Bad charset value \"%s\" - bad characters (RFC 8011 section 5.1.8)." msgstr "" -#: cups/ipp.c:5289 +#: cups/ipp.c:5171 #, c-format msgid "\"%s\": Bad charset value \"%s\" - bad length %d (RFC 8011 section 5.1.8)." msgstr "" -#: cups/ipp.c:4966 +#: cups/ipp.c:4922 #, c-format msgid "\"%s\": Bad dateTime UTC hours %u (RFC 8011 section 5.1.15)." msgstr "" -#: cups/ipp.c:4974 +#: cups/ipp.c:4928 #, c-format msgid "\"%s\": Bad dateTime UTC minutes %u (RFC 8011 section 5.1.15)." msgstr "" -#: cups/ipp.c:4958 +#: cups/ipp.c:4916 #, c-format msgid "\"%s\": Bad dateTime UTC sign '%c' (RFC 8011 section 5.1.15)." msgstr "" -#: cups/ipp.c:4918 +#: cups/ipp.c:4886 #, c-format msgid "\"%s\": Bad dateTime day %u (RFC 8011 section 5.1.15)." msgstr "" -#: cups/ipp.c:4950 +#: cups/ipp.c:4910 #, c-format msgid "\"%s\": Bad dateTime deciseconds %u (RFC 8011 section 5.1.15)." msgstr "" -#: cups/ipp.c:4926 +#: cups/ipp.c:4892 #, c-format msgid "\"%s\": Bad dateTime hours %u (RFC 8011 section 5.1.15)." msgstr "" -#: cups/ipp.c:4934 +#: cups/ipp.c:4898 #, c-format msgid "\"%s\": Bad dateTime minutes %u (RFC 8011 section 5.1.15)." msgstr "" -#: cups/ipp.c:4910 +#: cups/ipp.c:4880 #, c-format msgid "\"%s\": Bad dateTime month %u (RFC 8011 section 5.1.15)." msgstr "" -#: cups/ipp.c:4942 +#: cups/ipp.c:4904 #, c-format msgid "\"%s\": Bad dateTime seconds %u (RFC 8011 section 5.1.15)." msgstr "" -#: cups/ipp.c:4880 +#: cups/ipp.c:4856 #, c-format msgid "\"%s\": Bad enum value %d - out of range (RFC 8011 section 5.1.5)." msgstr "" -#: cups/ipp.c:5195 +#: cups/ipp.c:5101 #, c-format msgid "\"%s\": Bad keyword value \"%s\" - bad length %d (RFC 8011 section 5.1.4)." msgstr "" -#: cups/ipp.c:5186 +#: cups/ipp.c:5095 #, c-format msgid "\"%s\": Bad keyword value \"%s\" - invalid character (RFC 8011 section 5.1.4)." msgstr "" -#: cups/ipp.c:5389 +#: cups/ipp.c:5256 #, c-format msgid "\"%s\": Bad mimeMediaType value \"%s\" - bad characters (RFC 8011 section 5.1.10)." msgstr "" -#: cups/ipp.c:5399 +#: cups/ipp.c:5263 #, c-format msgid "\"%s\": Bad mimeMediaType value \"%s\" - bad length %d (RFC 8011 section 5.1.10)." msgstr "" -#: cups/ipp.c:5157 +#: cups/ipp.c:5071 #, c-format msgid "\"%s\": Bad name value \"%s\" - bad UTF-8 sequence (RFC 8011 section 5.1.3)." msgstr "" -#: cups/ipp.c:5166 +#: cups/ipp.c:5077 #, c-format msgid "\"%s\": Bad name value \"%s\" - bad length %d (RFC 8011 section 5.1.3)." msgstr "" -#: cups/ipp.c:5335 +#: cups/ipp.c:5211 #, c-format msgid "\"%s\": Bad naturalLanguage value \"%s\" - bad characters (RFC 8011 section 5.1.9)." msgstr "" -#: cups/ipp.c:5345 +#: cups/ipp.c:5218 #, c-format msgid "\"%s\": Bad naturalLanguage value \"%s\" - bad length %d (RFC 8011 section 5.1.9)." msgstr "" -#: cups/ipp.c:4894 +#: cups/ipp.c:4867 #, c-format msgid "\"%s\": Bad octetString value - bad length %d (RFC 8011 section 5.1.20)." msgstr "" -#: cups/ipp.c:5037 +#: cups/ipp.c:4962 #, c-format msgid "\"%s\": Bad rangeOfInteger value %d-%d - lower greater than upper (RFC 8011 section 5.1.14)." msgstr "" -#: cups/ipp.c:5018 +#: cups/ipp.c:4951 #, c-format msgid "\"%s\": Bad resolution value %dx%d%s - bad units value (RFC 8011 section 5.1.16)." msgstr "" -#: cups/ipp.c:4987 +#: cups/ipp.c:4939 #, c-format msgid "\"%s\": Bad resolution value %dx%d%s - cross feed resolution must be positive (RFC 8011 section 5.1.16)." msgstr "" -#: cups/ipp.c:5002 +#: cups/ipp.c:4945 #, c-format msgid "\"%s\": Bad resolution value %dx%d%s - feed resolution must be positive (RFC 8011 section 5.1.16)." msgstr "" -#: cups/ipp.c:5099 +#: cups/ipp.c:5020 #, c-format msgid "\"%s\": Bad text value \"%s\" - bad UTF-8 sequence (RFC 8011 section 5.1.2)." msgstr "" -#: cups/ipp.c:5108 +#: cups/ipp.c:5026 #, c-format msgid "\"%s\": Bad text value \"%s\" - bad length %d (RFC 8011 section 5.1.2)." msgstr "" -#: cups/ipp.c:5251 +#: cups/ipp.c:5141 #, c-format msgid "\"%s\": Bad uriScheme value \"%s\" - bad characters (RFC 8011 section 5.1.7)." msgstr "" -#: cups/ipp.c:5260 +#: cups/ipp.c:5147 #, c-format msgid "\"%s\": Bad uriScheme value \"%s\" - bad length %d (RFC 8011 section 5.1.7)." msgstr "" @@ -1849,7 +1849,7 @@ msgstr "" msgid "%s: Bad printer URI \"%s\"." msgstr "" -#: test/ippfind.c:770 test/ipptool.c:390 +#: test/ippfind.c:770 test/ipptool.c:411 #, c-format msgid "%s: Bad version %s for \"-V\"." msgstr "" @@ -2074,17 +2074,17 @@ msgstr "" msgid "%s: Invalid filter string \"%s\"." msgstr "" -#: test/ipptool.c:321 +#: test/ipptool.c:333 #, c-format msgid "%s: Missing filename for \"-P\"." msgstr "" -#: test/ippfind.c:742 test/ipptool.c:358 +#: test/ippfind.c:742 test/ipptool.c:370 #, c-format msgid "%s: Missing timeout for \"-T\"." msgstr "" -#: test/ippfind.c:755 test/ipptool.c:372 +#: test/ippfind.c:755 test/ipptool.c:384 #, c-format msgid "%s: Missing version for \"-V\"." msgstr "" @@ -2107,7 +2107,7 @@ msgstr "" #: berkeley/lpq.c:83 berkeley/lpr.c:64 berkeley/lprm.c:61 systemv/cancel.c:75 #: systemv/cupsaccept.c:85 systemv/cupsaddsmb.c:74 systemv/lp.c:95 #: systemv/lpadmin.c:247 systemv/lpinfo.c:188 systemv/lpmove.c:66 -#: systemv/lpstat.c:87 test/ipptool.c:303 test/ipptool.c:347 +#: systemv/lpstat.c:87 test/ipptool.c:315 test/ipptool.c:359 #, c-format msgid "%s: Sorry, no encryption support." msgstr "" @@ -2138,7 +2138,7 @@ msgstr "" msgid "%s: Unable to determine MIME type of \"%s\"." msgstr "" -#: test/ipptool.c:264 test/ipptool.c:330 +#: test/ipptool.c:276 test/ipptool.c:342 #, c-format msgid "%s: Unable to open \"%s\": %s" msgstr "" @@ -2188,7 +2188,7 @@ msgstr "" msgid "%s: Unknown option \"%s\"." msgstr "" -#: test/ippfind.c:921 +#: test/ippfind.c:921 test/ipptool.c:605 #, c-format msgid "%s: Unknown option \"-%c\"." msgstr "" @@ -4207,7 +4207,7 @@ msgstr "" msgid "IPP attribute has no name." msgstr "" -#: cups/ipp.c:7007 +#: cups/ipp.c:6868 msgid "IPP attribute is not a member of the message." msgstr "" @@ -4989,7 +4989,7 @@ msgstr "" #: scheduler/cupsfilter.c:1476 scheduler/main.c:2098 systemv/cupsaddsmb.c:272 #: systemv/cupsctl.c:190 systemv/cupstestdsc.c:415 systemv/cupstestppd.c:3853 -#: test/ippfind.c:2757 test/ipptool.c:5226 ppdc/ppdc.cxx:426 +#: test/ippfind.c:2757 test/ipptool.c:4215 ppdc/ppdc.cxx:426 #: ppdc/ppdhtml.cxx:173 ppdc/ppdi.cxx:119 ppdc/ppdmerge.cxx:357 #: ppdc/ppdpo.cxx:243 msgid "Options:" @@ -5756,12 +5756,12 @@ msgstr "" msgid "Unable to change server settings" msgstr "" -#: cups/ipp.c:5379 +#: cups/ipp.c:5248 #, c-format msgid "Unable to compile mimeMediaType regular expression: %s." msgstr "" -#: cups/ipp.c:5325 +#: cups/ipp.c:5203 #, c-format msgid "Unable to compile naturalLanguage regular expression: %s." msgstr "" @@ -6278,7 +6278,7 @@ msgid "" " ippfind --version" msgstr "" -#: test/ipptool.c:5225 +#: test/ipptool.c:4214 msgid "Usage: ipptool [options] URI filename [ ... filenameN ]" msgstr "" @@ -6605,56 +6605,51 @@ msgstr "" msgid "ippfind: Unknown variable \"{%s}\"." msgstr "" -#: test/ipptool.c:560 test/ipptool.c:583 +#: test/ipptool.c:565 test/ipptool.c:587 msgid "ipptool: \"-i\" and \"-n\" are incompatible with \"--ippserver\", \"-P\", and \"-X\"." msgstr "" -#: test/ipptool.c:338 test/ipptool.c:401 +#: test/ipptool.c:350 test/ipptool.c:421 msgid "ipptool: \"-i\" and \"-n\" are incompatible with \"-P\" and \"-X\"." msgstr "" -#: test/ipptool.c:639 +#: test/ipptool.c:633 #, c-format -msgid "ipptool: Bad URI - %s." +msgid "ipptool: Bad URI \"%s\"." msgstr "" -#: test/ipptool.c:553 +#: test/ipptool.c:558 msgid "ipptool: Invalid seconds for \"-i\"." msgstr "" -#: test/ipptool.c:620 +#: test/ipptool.c:622 msgid "ipptool: May only specify a single URI." msgstr "" -#: test/ipptool.c:575 +#: test/ipptool.c:579 msgid "ipptool: Missing count for \"-n\"." msgstr "" -#: test/ipptool.c:255 +#: test/ipptool.c:267 msgid "ipptool: Missing filename for \"--ippserver\"." msgstr "" -#: test/ipptool.c:435 +#: test/ipptool.c:455 msgid "ipptool: Missing filename for \"-f\"." msgstr "" -#: test/ipptool.c:416 +#: test/ipptool.c:436 msgid "ipptool: Missing name=value for \"-d\"." msgstr "" -#: test/ipptool.c:543 +#: test/ipptool.c:550 msgid "ipptool: Missing seconds for \"-i\"." msgstr "" -#: test/ipptool.c:665 +#: test/ipptool.c:648 msgid "ipptool: URI required before test file." msgstr "" -#: test/ipptool.c:601 -#, c-format -msgid "ipptool: Unknown option \"-%c\"." -msgstr "" - #: scheduler/ipp.c:8108 msgid "job-printer-uri attribute missing." msgstr "" diff --git a/locale/cups.strings b/locale/cups.strings index fc71c6c10..77f353b6b 100644 --- a/locale/cups.strings +++ b/locale/cups.strings @@ -311,7 +311,7 @@ "\"%s\": Bad URI value \"%s\" - bad length %d (RFC 8011 section 5.1.6)." = "“%s”: Bad URI value “%s” - bad length %d (RFC 8011 section 5.1.6)."; "\"%s\": Bad attribute name - bad length %d (RFC 8011 section 5.1.4)." = "“%s”: Bad attribute name - bad length %d (RFC 8011 section 5.1.4)."; "\"%s\": Bad attribute name - invalid character (RFC 8011 section 5.1.4)." = "“%s”: Bad attribute name - invalid character (RFC 8011 section 5.1.4)."; -"\"%s\": Bad boolen value %d (RFC 8011 section 5.1.21)." = "“%s”: Bad boolen value %d (RFC 8011 section 5.1.21)."; +"\"%s\": Bad boolean value %d (RFC 8011 section 5.1.21)." = "“%s”: Bad boolean value %d (RFC 8011 section 5.1.21)."; "\"%s\": Bad charset value \"%s\" - bad characters (RFC 8011 section 5.1.8)." = "“%s”: Bad charset value “%s” - bad characters (RFC 8011 section 5.1.8)."; "\"%s\": Bad charset value \"%s\" - bad length %d (RFC 8011 section 5.1.8)." = "“%s”: Bad charset value “%s” - bad length %d (RFC 8011 section 5.1.8)."; "\"%s\": Bad dateTime UTC hours %u (RFC 8011 section 5.1.15)." = "“%s”: Bad dateTime UTC hours %u (RFC 8011 section 5.1.15)."; @@ -1475,7 +1475,7 @@ "ippfind: Unknown variable \"{%s}\"." = "ippfind: Unknown variable “{%s}”."; "ipptool: \"-i\" and \"-n\" are incompatible with \"--ippserver\", \"-P\", and \"-X\"." = "ipptool: “-i” and “-n” are incompatible with “--ippserver”, “-P”, and “-X”."; "ipptool: \"-i\" and \"-n\" are incompatible with \"-P\" and \"-X\"." = "ipptool: “-i” and “-n” are incompatible with “-P” and “-X”."; -"ipptool: Bad URI - %s." = "ipptool: Bad URI - %s."; +"ipptool: Bad URI \"%s\"." = "ipptool: Bad URI “%s”."; "ipptool: Invalid seconds for \"-i\"." = "ipptool: Invalid seconds for “-i”."; "ipptool: May only specify a single URI." = "ipptool: May only specify a single URI."; "ipptool: Missing count for \"-n\"." = "ipptool: Missing count for “-n”."; @@ -1484,7 +1484,6 @@ "ipptool: Missing name=value for \"-d\"." = "ipptool: Missing name=value for “-d”."; "ipptool: Missing seconds for \"-i\"." = "ipptool: Missing seconds for “-i”."; "ipptool: URI required before test file." = "ipptool: URI required before test file."; -"ipptool: Unknown option \"-%c\"." = "ipptool: Unknown option “-%c”."; "job-printer-uri attribute missing." = "job-printer-uri attribute missing."; "lpadmin: Class name can only contain printable characters." = "lpadmin: Class name can only contain printable characters."; "lpadmin: Expected PPD after \"-%c\" option." = "lpadmin: Expected PPD after “-%c” option."; diff --git a/locale/cups_ca.po b/locale/cups_ca.po index 856f5e9c5..0f05a5c08 100644 --- a/locale/cups_ca.po +++ b/locale/cups_ca.po @@ -32,7 +32,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 1.4.6\n" "Report-Msgid-Bugs-To: https://github.com/apple/cups/issues\n" -"POT-Creation-Date: 2018-01-18 13:08-0500\n" +"POT-Creation-Date: 2018-01-31 14:22-0500\n" "PO-Revision-Date: 2012-09-29 11:21+0200\n" "Last-Translator: Àngel Mompó \n" "Language-Team: Catalan \n" @@ -1396,7 +1396,7 @@ msgid "" msgstr "" #, c-format -msgid "\"%s\": Bad boolen value %d (RFC 8011 section 5.1.21)." +msgid "\"%s\": Bad boolean value %d (RFC 8011 section 5.1.21)." msgstr "" #, c-format @@ -6591,8 +6591,8 @@ msgid "ipptool: \"-i\" and \"-n\" are incompatible with \"-P\" and \"-X\"." msgstr "" #, c-format -msgid "ipptool: Bad URI - %s." -msgstr "ipptool: l'URI no es correcte - %s." +msgid "ipptool: Bad URI \"%s\"." +msgstr "" msgid "ipptool: Invalid seconds for \"-i\"." msgstr "ipptool: els segons de «-i» no són correctes." @@ -6618,10 +6618,6 @@ msgstr "ipptool: falten els segons a «-i»." msgid "ipptool: URI required before test file." msgstr "ipptool: falta l'URI abans del fitxer de prova." -#, c-format -msgid "ipptool: Unknown option \"-%c\"." -msgstr "ipptool: l'opció «-%c» és desconeguda." - msgid "job-account-id" msgstr "Job Account ID" @@ -13029,6 +13025,9 @@ msgstr "" #~ msgid "ipptool: \"-n\" is incompatible with \"-X\"." #~ msgstr "ipptool: «-n» no és compatible amb «-X»." +#~ msgid "ipptool: Bad URI - %s." +#~ msgstr "ipptool: l'URI no es correcte - %s." + #~ msgid "ipptool: Bad version %s for \"-V\"." #~ msgstr "ipptool: la versió %s de «-V» no és correcta." @@ -13038,6 +13037,9 @@ msgstr "" #~ msgid "ipptool: Missing version for \"-V\"." #~ msgstr "ipptool: falta la versió a «-V»." +#~ msgid "ipptool: Unknown option \"-%c\"." +#~ msgstr "ipptool: l'opció «-%c» és desconeguda." + #~ msgid "job-authorization-uri" #~ msgstr "Job Authorization URI" diff --git a/locale/cups_cs.po b/locale/cups_cs.po index a771ac4ac..4406be0cb 100644 --- a/locale/cups_cs.po +++ b/locale/cups_cs.po @@ -29,7 +29,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 1.6\n" "Report-Msgid-Bugs-To: https://github.com/apple/cups/issues\n" -"POT-Creation-Date: 2018-01-18 13:08-0500\n" +"POT-Creation-Date: 2018-01-31 14:22-0500\n" "PO-Revision-Date: 2012-09-14 10:26+0100\n" "Last-Translator: Jan Bartos \n" "Language-Team: Czech\n" @@ -1219,7 +1219,7 @@ msgid "" msgstr "" #, c-format -msgid "\"%s\": Bad boolen value %d (RFC 8011 section 5.1.21)." +msgid "\"%s\": Bad boolean value %d (RFC 8011 section 5.1.21)." msgstr "" #, c-format @@ -6321,7 +6321,7 @@ msgid "ipptool: \"-i\" and \"-n\" are incompatible with \"-P\" and \"-X\"." msgstr "" #, c-format -msgid "ipptool: Bad URI - %s." +msgid "ipptool: Bad URI \"%s\"." msgstr "" msgid "ipptool: Invalid seconds for \"-i\"." @@ -6348,10 +6348,6 @@ msgstr "" msgid "ipptool: URI required before test file." msgstr "" -#, c-format -msgid "ipptool: Unknown option \"-%c\"." -msgstr "" - msgid "job-account-id" msgstr "Job Account ID" diff --git a/locale/cups_es.po b/locale/cups_es.po index 2a9b9ecec..995661b81 100644 --- a/locale/cups_es.po +++ b/locale/cups_es.po @@ -16,7 +16,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 2.2\n" "Report-Msgid-Bugs-To: https://github.com/apple/cups/issues\n" -"POT-Creation-Date: 2018-01-18 13:08-0500\n" +"POT-Creation-Date: 2018-01-31 14:22-0500\n" "PO-Revision-Date: 2016-06-26 21:17+0100\n" "Last-Translator: Juan Pablo González Riopedre \n" "Language-Team: Spanish\n" @@ -1426,7 +1426,7 @@ msgid "" msgstr "" #, c-format -msgid "\"%s\": Bad boolen value %d (RFC 8011 section 5.1.21)." +msgid "\"%s\": Bad boolean value %d (RFC 8011 section 5.1.21)." msgstr "" #, c-format @@ -6639,8 +6639,8 @@ msgid "ipptool: \"-i\" and \"-n\" are incompatible with \"-P\" and \"-X\"." msgstr "ipptool: \"-i\" y \"-n\" no son compatibles con \"-P\" y \"-X\"." #, c-format -msgid "ipptool: Bad URI - %s." -msgstr "ipptool: URI - %s incorrecto." +msgid "ipptool: Bad URI \"%s\"." +msgstr "" msgid "ipptool: Invalid seconds for \"-i\"." msgstr "ipptool: Número de segundos no válido para \"-i\"." @@ -6666,10 +6666,6 @@ msgstr "ipptool: Falta el número de segundos para \"-i\"." msgid "ipptool: URI required before test file." msgstr "ipptool: Se requiere un URI antes del archivo de prueba." -#, c-format -msgid "ipptool: Unknown option \"-%c\"." -msgstr "ipptool: Opción \"-%c\" desconocida." - msgid "job-account-id" msgstr "Job Account ID" @@ -13297,6 +13293,12 @@ msgstr "" #~ msgid "ipp-attribute-fidelity" #~ msgstr "Attribute Fidelity" +#~ msgid "ipptool: Bad URI - %s." +#~ msgstr "ipptool: URI - %s incorrecto." + +#~ msgid "ipptool: Unknown option \"-%c\"." +#~ msgstr "ipptool: Opción \"-%c\" desconocida." + #~ msgid "job-authorization-uri" #~ msgstr "Job Authorization URI" diff --git a/locale/cups_fr.po b/locale/cups_fr.po index fa406ec69..34cbc2e63 100644 --- a/locale/cups_fr.po +++ b/locale/cups_fr.po @@ -29,7 +29,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 1.6\n" "Report-Msgid-Bugs-To: https://github.com/apple/cups/issues\n" -"POT-Creation-Date: 2018-01-18 13:08-0500\n" +"POT-Creation-Date: 2018-01-31 14:22-0500\n" "PO-Revision-Date: 2012-12-12 11:12+0100\n" "Last-Translator: Stéphane Blondon \n" "Language-Team: LANGUAGE \n" @@ -1279,7 +1279,7 @@ msgid "" msgstr "" #, c-format -msgid "\"%s\": Bad boolen value %d (RFC 8011 section 5.1.21)." +msgid "\"%s\": Bad boolean value %d (RFC 8011 section 5.1.21)." msgstr "" #, c-format @@ -6388,7 +6388,7 @@ msgid "ipptool: \"-i\" and \"-n\" are incompatible with \"-P\" and \"-X\"." msgstr "" #, c-format -msgid "ipptool: Bad URI - %s." +msgid "ipptool: Bad URI \"%s\"." msgstr "" msgid "ipptool: Invalid seconds for \"-i\"." @@ -6415,10 +6415,6 @@ msgstr "" msgid "ipptool: URI required before test file." msgstr "" -#, c-format -msgid "ipptool: Unknown option \"-%c\"." -msgstr "" - msgid "job-account-id" msgstr "Job Account ID" diff --git a/locale/cups_it.po b/locale/cups_it.po index 91f1b6e39..c1e99ad7d 100644 --- a/locale/cups_it.po +++ b/locale/cups_it.po @@ -29,7 +29,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 1.6\n" "Report-Msgid-Bugs-To: https://github.com/apple/cups/issues\n" -"POT-Creation-Date: 2018-01-18 13:08-0500\n" +"POT-Creation-Date: 2018-01-31 14:22-0500\n" "PO-Revision-Date: 2013-07-14 12:00+0200\n" "Last-Translator: Giovanni Scafora \n" "Language-Team: Arch Linux Italian Team \n" @@ -1421,7 +1421,7 @@ msgid "" msgstr "" #, c-format -msgid "\"%s\": Bad boolen value %d (RFC 8011 section 5.1.21)." +msgid "\"%s\": Bad boolean value %d (RFC 8011 section 5.1.21)." msgstr "" #, c-format @@ -6612,8 +6612,8 @@ msgid "ipptool: \"-i\" and \"-n\" are incompatible with \"-P\" and \"-X\"." msgstr "" #, c-format -msgid "ipptool: Bad URI - %s." -msgstr "ipptool: l'URI non è valido - %s." +msgid "ipptool: Bad URI \"%s\"." +msgstr "" msgid "ipptool: Invalid seconds for \"-i\"." msgstr "ipptool: secondi non validi per \"-i\"." @@ -6639,10 +6639,6 @@ msgstr "ipptool: mancano i secondi per \"-i\"." msgid "ipptool: URI required before test file." msgstr "ipptool: l'URI è richiesto prima del file di testo." -#, c-format -msgid "ipptool: Unknown option \"-%c\"." -msgstr "ipptool: opzione sconosciuta \"-%c\"." - msgid "job-account-id" msgstr "Job Account ID" @@ -13066,6 +13062,12 @@ msgstr "" #~ msgid "ipptool: \"-i\" and \"-n\" are incompatible with -X\"." #~ msgstr "ipptool: \"-i\" e \"-n\" sono incompatibili con -X\"." +#~ msgid "ipptool: Bad URI - %s." +#~ msgstr "ipptool: l'URI non è valido - %s." + +#~ msgid "ipptool: Unknown option \"-%c\"." +#~ msgstr "ipptool: opzione sconosciuta \"-%c\"." + #~ msgid "job-authorization-uri" #~ msgstr "Job Authorization URI" diff --git a/locale/cups_ja.po b/locale/cups_ja.po index 4407cc8f9..c5d8f4b21 100644 --- a/locale/cups_ja.po +++ b/locale/cups_ja.po @@ -28,7 +28,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 2.0\n" "Report-Msgid-Bugs-To: https://github.com/apple/cups/issues\n" -"POT-Creation-Date: 2018-01-18 13:08-0500\n" +"POT-Creation-Date: 2018-01-31 14:22-0500\n" "PO-Revision-Date: 2014-11-15 19:27+0900\n" "Last-Translator: OPFC TRANSCUPS \n" "Language-Team: OPFC TRANSCUPS \n" @@ -1397,7 +1397,7 @@ msgid "" msgstr "" #, c-format -msgid "\"%s\": Bad boolen value %d (RFC 8011 section 5.1.21)." +msgid "\"%s\": Bad boolean value %d (RFC 8011 section 5.1.21)." msgstr "" #, c-format @@ -6574,8 +6574,8 @@ msgstr "" "ipptool: \"-i\" および \"-n\" は \"-P\"、\"-X\" と一緒に指定できません。" #, c-format -msgid "ipptool: Bad URI - %s." -msgstr "ipptool: 不正な URI です - %s。" +msgid "ipptool: Bad URI \"%s\"." +msgstr "" msgid "ipptool: Invalid seconds for \"-i\"." msgstr "ipptool: \"-i\" に不正な秒数が指定されました。" @@ -6601,10 +6601,6 @@ msgstr "ipptool: \"-i\" に秒数の指定がありません。" msgid "ipptool: URI required before test file." msgstr "ipptool: テストファイルの前に URI の指定が必要です。" -#, c-format -msgid "ipptool: Unknown option \"-%c\"." -msgstr "ipptool: \"-%c\"は未知のオプションです。" - msgid "job-account-id" msgstr "Job Account ID" @@ -13117,6 +13113,9 @@ msgstr "" #~ msgid "ipptool: \"-i\" and \"-n\" are incompatible with -X\"." #~ msgstr "ipptool: \"-i\" と \"-n\" は \"-X\" と組み合わせられません。" +#~ msgid "ipptool: Bad URI - %s." +#~ msgstr "ipptool: 不正な URI です - %s。" + #~ msgid "ipptool: Bad version %s for \"-V\"." #~ msgstr "ipptool: \"-V\" オプションに不正なバージョン %s が指定されました。" @@ -13126,6 +13125,9 @@ msgstr "" #~ msgid "ipptool: Missing version for \"-V\"." #~ msgstr "ipptool: \"-V\" にバージョンの指定がありません。" +#~ msgid "ipptool: Unknown option \"-%c\"." +#~ msgstr "ipptool: \"-%c\"は未知のオプションです。" + #~ msgid "job-authorization-uri" #~ msgstr "Job Authorization URI" diff --git a/locale/cups_pt_BR.po b/locale/cups_pt_BR.po index 9a977f107..da4b5b069 100644 --- a/locale/cups_pt_BR.po +++ b/locale/cups_pt_BR.po @@ -40,7 +40,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 2.1.2\n" "Report-Msgid-Bugs-To: https://github.com/apple/cups/issues\n" -"POT-Creation-Date: 2018-01-18 13:08-0500\n" +"POT-Creation-Date: 2018-01-31 14:22-0500\n" "PO-Revision-Date: 2016-01-31 16:45-0200\n" "Last-Translator: Rafael Fontenelle \n" "Language-Team: Brazilian Portuguese \n" @@ -1430,7 +1430,7 @@ msgid "" msgstr "" #, c-format -msgid "\"%s\": Bad boolen value %d (RFC 8011 section 5.1.21)." +msgid "\"%s\": Bad boolean value %d (RFC 8011 section 5.1.21)." msgstr "" #, c-format @@ -6618,8 +6618,8 @@ msgid "ipptool: \"-i\" and \"-n\" are incompatible with \"-P\" and \"-X\"." msgstr "ipptool: \"-i\" e \"-n\" são incompatíveis com \"-P\" e \"-X\"." #, c-format -msgid "ipptool: Bad URI - %s." -msgstr "ipptool: URI inválida - %s." +msgid "ipptool: Bad URI \"%s\"." +msgstr "" msgid "ipptool: Invalid seconds for \"-i\"." msgstr "ipptool: Segundos inválidos para \"-i\"." @@ -6645,10 +6645,6 @@ msgstr "ipptool: Faltando segundos para \"-i\"." msgid "ipptool: URI required before test file." msgstr "ipptool: URI necessária antes do arquivo de teste." -#, c-format -msgid "ipptool: Unknown option \"-%c\"." -msgstr "ipptool: Opção desconhecida \"-%c\"." - msgid "job-account-id" msgstr "Job Account ID" @@ -13088,6 +13084,12 @@ msgstr "" #~ msgid "ipptool: \"-i\" and \"-n\" are incompatible with -X\"." #~ msgstr "ipptool: \"-i\" e \"-n\" são incompatíveis com \"-X\"." +#~ msgid "ipptool: Bad URI - %s." +#~ msgstr "ipptool: URI inválida - %s." + +#~ msgid "ipptool: Unknown option \"-%c\"." +#~ msgstr "ipptool: Opção desconhecida \"-%c\"." + #~ msgid "job-authorization-uri" #~ msgstr "Job Authorization URI" diff --git a/locale/cups_ru.po b/locale/cups_ru.po index 7690371ef..fc5ec9541 100644 --- a/locale/cups_ru.po +++ b/locale/cups_ru.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 2.0\n" "Report-Msgid-Bugs-To: https://github.com/apple/cups/issues\n" -"POT-Creation-Date: 2018-01-18 13:08-0500\n" +"POT-Creation-Date: 2018-01-31 14:22-0500\n" "PO-Revision-Date: 2015-01-28 12:00-0800\n" "Last-Translator: Aleksandr Proklov\n" "Language-Team: PuppyRus Linux Team\n" @@ -1358,7 +1358,7 @@ msgid "" msgstr "" #, c-format -msgid "\"%s\": Bad boolen value %d (RFC 8011 section 5.1.21)." +msgid "\"%s\": Bad boolean value %d (RFC 8011 section 5.1.21)." msgstr "" #, c-format @@ -6529,8 +6529,8 @@ msgid "ipptool: \"-i\" and \"-n\" are incompatible with \"-P\" and \"-X\"." msgstr "ipptool: Параметры \"-i\" и \"-n\" несовместимы с \"-P\" и \"-X\"." #, c-format -msgid "ipptool: Bad URI - %s." -msgstr "ipptool: Неправильный URI - %s." +msgid "ipptool: Bad URI \"%s\"." +msgstr "" msgid "ipptool: Invalid seconds for \"-i\"." msgstr "ipptool: Неправильные секунды для \"-i\"." @@ -6556,10 +6556,6 @@ msgstr "ipptool: Отсутствуют секунды для \"-i\"." msgid "ipptool: URI required before test file." msgstr "ipptool: Необходим URI перед указанием тест-файла." -#, c-format -msgid "ipptool: Unknown option \"-%c\"." -msgstr "ipptool: Неизвестный параметр \"-%c\"." - msgid "job-account-id" msgstr "Job Account ID" @@ -12871,6 +12867,12 @@ msgstr "" #~ msgid "ipp-attribute-fidelity" #~ msgstr "Attribute Fidelity" +#~ msgid "ipptool: Bad URI - %s." +#~ msgstr "ipptool: Неправильный URI - %s." + +#~ msgid "ipptool: Unknown option \"-%c\"." +#~ msgstr "ipptool: Неизвестный параметр \"-%c\"." + #~ msgid "job-authorization-uri" #~ msgstr "Job Authorization URI" diff --git a/locale/cups_zh_CN.po b/locale/cups_zh_CN.po index d39026140..fc29e82a4 100644 --- a/locale/cups_zh_CN.po +++ b/locale/cups_zh_CN.po @@ -29,7 +29,7 @@ msgid "" msgstr "" "Project-Id-Version: CUPS 1.6\n" "Report-Msgid-Bugs-To: https://github.com/apple/cups/issues\n" -"POT-Creation-Date: 2018-01-18 13:08-0500\n" +"POT-Creation-Date: 2018-01-31 14:22-0500\n" "PO-Revision-Date: 2017-06-11 12:38+0800\n" "Last-Translator: Mingcong Bai \n" "Language-Team: \n" @@ -1352,7 +1352,7 @@ msgid "" msgstr "" #, c-format -msgid "\"%s\": Bad boolen value %d (RFC 8011 section 5.1.21)." +msgid "\"%s\": Bad boolean value %d (RFC 8011 section 5.1.21)." msgstr "" #, c-format @@ -6487,8 +6487,8 @@ msgid "ipptool: \"-i\" and \"-n\" are incompatible with \"-P\" and \"-X\"." msgstr "ipptool:“-i”和“-n”不能与“-P”和“-X”混用。" #, c-format -msgid "ipptool: Bad URI - %s." -msgstr "ipptool:无效 URI — %s。" +msgid "ipptool: Bad URI \"%s\"." +msgstr "" msgid "ipptool: Invalid seconds for \"-i\"." msgstr "ipptool:“-i”选项后指定的秒数无效。" @@ -6514,10 +6514,6 @@ msgstr "ipptool:“-i”选项后缺少秒数。" msgid "ipptool: URI required before test file." msgstr "ipptool:测试文件前需要 URI。" -#, c-format -msgid "ipptool: Unknown option \"-%c\"." -msgstr "ipptool:未知选项“-%c”。" - msgid "job-account-id" msgstr "Job Account ID" @@ -13578,6 +13574,12 @@ msgstr "" #~ msgid "ipp-attribute-fidelity" #~ msgstr "Attribute Fidelity" +#~ msgid "ipptool: Bad URI - %s." +#~ msgstr "ipptool:无效 URI — %s。" + +#~ msgid "ipptool: Unknown option \"-%c\"." +#~ msgstr "ipptool:未知选项“-%c”。" + #~ msgid "job-authorization-uri" #~ msgstr "Job Authorization URI" diff --git a/test/ipptool.c b/test/ipptool.c index a2d0ee609..5b31b4df0 100644 --- a/test/ipptool.c +++ b/test/ipptool.c @@ -192,7 +192,6 @@ static void sigterm_handler(int sig); static int timeout_cb(http_t *http, void *user_data); static int token_cb(_ipp_file_t *f, _ipp_vars_t *vars, _cups_testdata_t *data, const char *token); static void usage(void) __attribute__((noreturn)); -static int validate_attr(_cups_testdata_t *data, cups_array_t *errors, ipp_attribute_t *attr); static const char *with_flags_string(int flags); static int with_value(_cups_testdata_t *data, cups_array_t *errors, char *value, int flags, ipp_attribute_t *attr, char *matchbuf, size_t matchlen); static int with_value_from(cups_array_t *errors, ipp_attribute_t *fromattr, ipp_attribute_t *attr, char *matchbuf, size_t matchlen); @@ -1266,7 +1265,8 @@ do_test(_ipp_file_t *f, /* I - IPP data file */ group = ippGetGroupTag(attrptr); } - validate_attr(data, data->errors, attrptr); + if (!ippValidateAttribute(attrptr)) + cupsArrayAdd(data->errors, (void *)cupsLastErrorString()); if (ippGetName(attrptr)) { @@ -4245,608 +4245,6 @@ usage(void) } -/* - * 'validate_attr()' - Determine whether an attribute is valid. - */ - -static int /* O - 1 if valid, 0 otherwise */ -validate_attr(_cups_testdata_t *data, /* I - Test data */ - cups_array_t *errors, /* I - Errors array */ - ipp_attribute_t *attr) /* I - Attribute to validate */ -{ - int i, /* Looping var */ - count; /* Number of values */ - char scheme[64], /* Scheme from URI */ - userpass[256], /* Username/password from URI */ - hostname[256], /* Hostname from URI */ - resource[1024]; /* Resource from URI */ - int port, /* Port number from URI */ - uri_status, /* URI separation status */ - valid = 1; /* Is the attribute valid? */ - const char *name, /* Attribute name */ - *ptr; /* Pointer into string */ - ipp_attribute_t *colattr; /* Collection attribute */ - regex_t re; /* Regular expression */ - - - /* - * Skip separators. - */ - - if ((name = ippGetName(attr)) == NULL) - return (1); - - /* - * Validate the attribute name. - */ - - for (ptr = name; *ptr; ptr ++) - if (!isalnum(*ptr & 255) && *ptr != '-' && *ptr != '.' && *ptr != '_') - break; - - if (*ptr || ptr == name) - { - valid = 0; - - add_stringf(data->errors, - "\"%s\": Bad attribute name - invalid character " - "(RFC 2911 section 4.1.3).", name); - } - - if ((ptr - ippGetName(attr)) > 255) - { - valid = 0; - - add_stringf(data->errors, - "\"%s\": Bad attribute name - bad length " - "(RFC 2911 section 4.1.3).", name); - } - - count = ippGetCount(attr); - - switch (ippGetValueTag(attr)) - { - case IPP_TAG_INTEGER : - break; - - case IPP_TAG_BOOLEAN : - for (i = 0; i < count; i ++) - { - int b = ippGetBoolean(attr, i); - /* Boolean value */ - - if (b != 0 && b != 1) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad boolen value %d (RFC 2911 section 4.1.11).", name, b); - } - } - break; - - case IPP_TAG_ENUM : - for (i = 0; i < count; i ++) - { - if (ippGetInteger(attr, i) < 1) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad enum value %d - out of range (RFC 2911 section 4.1.4).", name, ippGetInteger(attr, i)); - } - } - break; - - case IPP_TAG_STRING : - for (i = 0; i < count; i ++) - { - int datalen; /* Length of string */ - - ippGetOctetString(attr, i, &datalen); - if (datalen > IPP_MAX_OCTETSTRING) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad octetString value - bad length %d (RFC 2911 section 4.1.10).", name, datalen); - } - } - break; - - case IPP_TAG_DATE : - for (i = 0; i < count; i ++) - { - const ipp_uchar_t *date = ippGetDate(attr, i); - /* Current date value */ - - if (date[2] < 1 || date[2] > 12) - { - valid = 0; - - add_stringf(data->errors, - "\"%s\": Bad dateTime month %u " - "(RFC 2911 section 4.1.14).", name, date[2]); - } - - if (date[3] < 1 || date[3] > 31) - { - valid = 0; - - add_stringf(data->errors, - "\"%s\": Bad dateTime day %u " - "(RFC 2911 section 4.1.14).", name, date[3]); - } - - if (date[4] > 23) - { - valid = 0; - - add_stringf(data->errors, - "\"%s\": Bad dateTime hours %u " - "(RFC 2911 section 4.1.14).", name, date[4]); - } - - if (date[5] > 59) - { - valid = 0; - - add_stringf(data->errors, - "\"%s\": Bad dateTime minutes %u " - "(RFC 2911 section 4.1.14).", name, date[5]); - } - - if (date[6] > 60) - { - valid = 0; - - add_stringf(data->errors, - "\"%s\": Bad dateTime seconds %u " - "(RFC 2911 section 4.1.14).", name, date[6]); - } - - if (date[7] > 9) - { - valid = 0; - - add_stringf(data->errors, - "\"%s\": Bad dateTime deciseconds %u " - "(RFC 2911 section 4.1.14).", name, date[7]); - } - - if (date[8] != '-' && date[8] != '+') - { - valid = 0; - - add_stringf(data->errors, - "\"%s\": Bad dateTime UTC sign '%c' " - "(RFC 2911 section 4.1.14).", name, date[8]); - } - - if (date[9] > 11) - { - valid = 0; - - add_stringf(data->errors, - "\"%s\": Bad dateTime UTC hours %u " - "(RFC 2911 section 4.1.14).", name, date[9]); - } - - if (date[10] > 59) - { - valid = 0; - - add_stringf(data->errors, - "\"%s\": Bad dateTime UTC minutes %u " - "(RFC 2911 section 4.1.14).", name, date[10]); - } - } - break; - - case IPP_TAG_RESOLUTION : - for (i = 0; i < count; i ++) - { - int xres, yres; /* Resolution values */ - ipp_res_t units; /* Resolution units */ - - xres = ippGetResolution(attr, i, &yres, &units); - - if (xres <= 0) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad resolution value %dx%d%s - cross feed resolution must be positive (RFC 2911 section 4.1.15).", name, xres, yres, units == IPP_RES_PER_INCH ? "dpi" : units == IPP_RES_PER_CM ? "dpcm" : "unknown"); - } - - if (yres <= 0) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad resolution value %dx%d%s - feed resolution must be positive (RFC 2911 section 4.1.15).", name, xres, yres, units == IPP_RES_PER_INCH ? "dpi" : units == IPP_RES_PER_CM ? "dpcm" : "unknown"); - } - - if (units != IPP_RES_PER_INCH && units != IPP_RES_PER_CM) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad resolution value %dx%d%s - bad units value (RFC 2911 section 4.1.15).", name, xres, yres, units == IPP_RES_PER_INCH ? "dpi" : units == IPP_RES_PER_CM ? "dpcm" : "unknown"); - } - } - break; - - case IPP_TAG_RANGE : - for (i = 0; i < count; i ++) - { - int lower, upper; /* Range values */ - - lower = ippGetRange(attr, i, &upper); - - if (lower > upper) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad rangeOfInteger value %d-%d - lower greater than upper (RFC 2911 section 4.1.13).", name, lower, upper); - } - } - break; - - case IPP_TAG_BEGIN_COLLECTION : - for (i = 0; i < count; i ++) - { - ipp_t *col = ippGetCollection(attr, i); - /* Collection value */ - - for (colattr = ippFirstAttribute(col); colattr; colattr = ippNextAttribute(col)) - { - if (!validate_attr(data, NULL, colattr)) - { - valid = 0; - break; - } - } - - if (colattr && errors) - { - add_stringf(data->errors, "\"%s\": Bad collection value.", name); - - while (colattr) - { - validate_attr(data, errors, colattr); - colattr = ippNextAttribute(col); - } - } - } - break; - - case IPP_TAG_TEXT : - case IPP_TAG_TEXTLANG : - for (i = 0; i < count; i ++) - { - const char *s = ippGetString(attr, i, NULL); - /* Text value */ - - for (ptr = s; *ptr; ptr ++) - { - if ((*ptr & 0xe0) == 0xc0) - { - ptr ++; - if ((*ptr & 0xc0) != 0x80) - break; - } - else if ((*ptr & 0xf0) == 0xe0) - { - ptr ++; - if ((*ptr & 0xc0) != 0x80) - break; - ptr ++; - if ((*ptr & 0xc0) != 0x80) - break; - } - else if ((*ptr & 0xf8) == 0xf0) - { - ptr ++; - if ((*ptr & 0xc0) != 0x80) - break; - ptr ++; - if ((*ptr & 0xc0) != 0x80) - break; - ptr ++; - if ((*ptr & 0xc0) != 0x80) - break; - } - else if (*ptr & 0x80) - break; - } - - if (*ptr) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad text value \"%s\" - bad UTF-8 sequence (RFC 2911 section 4.1.1).", name, s); - } - - if ((ptr - s) > (IPP_MAX_TEXT - 1)) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad text value \"%s\" - bad length %d (RFC 2911 section 4.1.1).", name, s, (int)strlen(s)); - } - } - break; - - case IPP_TAG_NAME : - case IPP_TAG_NAMELANG : - for (i = 0; i < count; i ++) - { - const char *s = ippGetString(attr, i, NULL); - /* Name value */ - - for (ptr = s; *ptr; ptr ++) - { - if ((*ptr & 0xe0) == 0xc0) - { - ptr ++; - if ((*ptr & 0xc0) != 0x80) - break; - } - else if ((*ptr & 0xf0) == 0xe0) - { - ptr ++; - if ((*ptr & 0xc0) != 0x80) - break; - ptr ++; - if ((*ptr & 0xc0) != 0x80) - break; - } - else if ((*ptr & 0xf8) == 0xf0) - { - ptr ++; - if ((*ptr & 0xc0) != 0x80) - break; - ptr ++; - if ((*ptr & 0xc0) != 0x80) - break; - ptr ++; - if ((*ptr & 0xc0) != 0x80) - break; - } - else if (*ptr & 0x80) - break; - } - - if (*ptr) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad name value \"%s\" - bad UTF-8 sequence (RFC 2911 section 4.1.2).", name, s); - } - - if ((ptr - s) > (IPP_MAX_NAME - 1)) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad name value \"%s\" - bad length %d (RFC 2911 section 4.1.2).", name, s, (int)strlen(s)); - } - } - break; - - case IPP_TAG_KEYWORD : - for (i = 0; i < count; i ++) - { - const char *keyword = ippGetString(attr, i, NULL); - /* Keyword value */ - - for (ptr = keyword; *ptr; ptr ++) - if (!isalnum(*ptr & 255) && *ptr != '-' && *ptr != '.' && - *ptr != '_') - break; - - if (*ptr || ptr == keyword) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad keyword value \"%s\" - invalid character (RFC 2911 section 4.1.3).", name, keyword); - } - - if ((ptr - keyword) > (IPP_MAX_KEYWORD - 1)) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad keyword value \"%s\" - bad length %d (RFC 2911 section 4.1.3).", name, keyword, (int)strlen(keyword)); - } - } - break; - - case IPP_TAG_URI : - for (i = 0; i < count; i ++) - { - const char *uri = ippGetString(attr, i, NULL); - /* URI value */ - - uri_status = httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, resource, sizeof(resource)); - - if (uri_status < HTTP_URI_OK) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad URI value \"%s\" - %s (RFC 2911 section 4.1.5).", name, uri, httpURIStatusString(uri_status)); - } - - if (strlen(uri) > (IPP_MAX_URI - 1)) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad URI value \"%s\" - bad length %d (RFC 2911 section 4.1.5).", name, uri, (int)strlen(uri)); - } - } - break; - - case IPP_TAG_URISCHEME : - for (i = 0; i < count; i ++) - { - const char *urischeme = ippGetString(attr, i, NULL); - /* URI scheme value */ - - ptr = urischeme; - if (islower(*ptr & 255)) - { - for (ptr ++; *ptr; ptr ++) - if (!islower(*ptr & 255) && !isdigit(*ptr & 255) && - *ptr != '+' && *ptr != '-' && *ptr != '.') - break; - } - - if (*ptr || ptr == urischeme) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad uriScheme value \"%s\" - bad characters (RFC 2911 section 4.1.6).", name, urischeme); - } - - if ((ptr - urischeme) > (IPP_MAX_URISCHEME - 1)) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad uriScheme value \"%s\" - bad length %d (RFC 2911 section 4.1.6).", name, urischeme, (int)strlen(urischeme)); - } - } - break; - - case IPP_TAG_CHARSET : - for (i = 0; i < count; i ++) - { - const char *charset = ippGetString(attr, i, NULL); - /* Charset value */ - - for (ptr = charset; *ptr; ptr ++) - if (!isprint(*ptr & 255) || isupper(*ptr & 255) || - isspace(*ptr & 255)) - break; - - if (*ptr || ptr == charset) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad charset value \"%s\" - bad characters (RFC 2911 section 4.1.7).", name, charset); - } - - if ((ptr - charset) > (IPP_MAX_CHARSET - 1)) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad charset value \"%s\" - bad length %d (RFC 2911 section 4.1.7).", name, charset, (int)strlen(charset)); - } - } - break; - - case IPP_TAG_LANGUAGE : - /* - * The following regular expression is derived from the ABNF for - * language tags in RFC 4646. All I can say is that this is the - * easiest way to check the values... - */ - - if ((i = regcomp(&re, - "^(" - "(([a-z]{2,3}(-[a-z][a-z][a-z]){0,3})|[a-z]{4,8})" - /* language */ - "(-[a-z][a-z][a-z][a-z]){0,1}" /* script */ - "(-([a-z][a-z]|[0-9][0-9][0-9])){0,1}" /* region */ - "(-([a-z]{5,8}|[0-9][0-9][0-9]))*" /* variant */ - "(-[a-wy-z](-[a-z0-9]{2,8})+)*" /* extension */ - "(-x(-[a-z0-9]{1,8})+)*" /* privateuse */ - "|" - "x(-[a-z0-9]{1,8})+" /* privateuse */ - "|" - "[a-z]{1,3}(-[a-z][0-9]{2,8}){1,2}" /* grandfathered */ - ")$", - REG_NOSUB | REG_EXTENDED)) != 0) - { - char temp[256]; /* Temporary error string */ - - regerror(i, &re, temp, sizeof(temp)); - print_fatal_error(data, "Unable to compile naturalLanguage regular " - "expression: %s.", temp); - break; - } - - for (i = 0; i < count; i ++) - { - const char *lang = ippGetString(attr, i, NULL); - /* Language string */ - - if (regexec(&re, lang, 0, NULL, 0)) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad naturalLanguage value \"%s\" - bad characters (RFC 2911 section 4.1.8).", name, lang); - } - - if (strlen(lang) > (IPP_MAX_LANGUAGE - 1)) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad naturalLanguage value \"%s\" - bad length %d (RFC 2911 section 4.1.8).", name, lang, (int)strlen(lang)); - } - } - - regfree(&re); - break; - - case IPP_TAG_MIMETYPE : - /* - * The following regular expression is derived from the ABNF for - * language tags in RFC 2045 and 4288. All I can say is that this is - * the easiest way to check the values... - */ - - if ((i = regcomp(&re, - "^" - "[-a-zA-Z0-9!#$&.+^_]{1,127}" /* type-name */ - "/" - "[-a-zA-Z0-9!#$&.+^_]{1,127}" /* subtype-name */ - "(;[-a-zA-Z0-9!#$&.+^_]{1,127}=" /* parameter= */ - "([-a-zA-Z0-9!#$&.+^_]{1,127}|\"[^\"]*\"))*" - /* value */ - "$", - REG_NOSUB | REG_EXTENDED)) != 0) - { - char temp[256]; /* Temporary error string */ - - regerror(i, &re, temp, sizeof(temp)); - print_fatal_error(data, "Unable to compile mimeMediaType regular " - "expression: %s.", temp); - break; - } - - for (i = 0; i < count; i ++) - { - const char *mimetype = ippGetString(attr, i, NULL); - /* Mime media type string */ - - if (regexec(&re, mimetype, 0, NULL, 0)) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad mimeMediaType value \"%s\" - bad characters (RFC 2911 section 4.1.9).", name, mimetype); - } - - if (strlen(mimetype) > (IPP_MAX_MIMETYPE - 1)) - { - valid = 0; - - add_stringf(data->errors, "\"%s\": Bad mimeMediaType value \"%s\" - bad length %d (RFC 2911 section 4.1.9).", name, mimetype, (int)strlen(mimetype)); - } - } - - regfree(&re); - break; - - default : - break; - } - - return (valid); -} - - /* * 'with_flags_string()' - Return the "WITH-xxx" predicate that corresponds to the flags. -- 2.39.2