summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Untz <vuntz@suse.com>2012-03-27 16:12:12 +0200
committerVincent Untz <vuntz@suse.com>2012-03-27 16:12:12 +0200
commitc9e0f69aefcbd21bc0b5a981ef4d28eb9794a4a9 (patch)
tree3034797ebedcdeebb80f759a685c9cb332c7a47f
parent37d99581d2b3e94ecaaa24590572db4eaf46fd69 (diff)
Escape printer/class names before putting them in URIs
-rw-r--r--src/cups.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/cups.c b/src/cups.c
index 623cdf7..332abbe 100644
--- a/src/cups.c
+++ b/src/cups.c
@@ -474,10 +474,14 @@ static void
_cph_cups_add_printer_uri (ipp_t *request,
const char *name)
{
- char uri[HTTP_MAX_URI + 1];
+ char *escaped_name;
+ char uri[HTTP_MAX_URI + 1];
+ escaped_name = g_uri_escape_string (name, NULL, FALSE);
g_snprintf (uri, sizeof (uri),
- "ipp://localhost/printers/%s", name);
+ "ipp://localhost/printers/%s", escaped_name);
+ g_free (escaped_name);
+
ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
}
@@ -486,10 +490,14 @@ static void
_cph_cups_add_class_uri (ipp_t *request,
const char *name)
{
- char uri[HTTP_MAX_URI + 1];
+ char *escaped_name;
+ char uri[HTTP_MAX_URI + 1];
+ escaped_name = g_uri_escape_string (name, NULL, FALSE);
g_snprintf (uri, sizeof (uri),
- "ipp://localhost/classes/%s", name);
+ "ipp://localhost/classes/%s", escaped_name);
+ g_free (escaped_name);
+
ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
}
@@ -1702,6 +1710,7 @@ cph_cups_class_add_printer (CphCups *cups,
ipp_t *request;
int new_len;
ipp_attribute_t *printer_uris;
+ char *escaped_printer_name;
char printer_uri[HTTP_MAX_URI + 1];
ipp_attribute_t *attr;
@@ -1736,8 +1745,10 @@ cph_cups_class_add_printer (CphCups *cups,
_cph_cups_add_class_uri (request, class_name);
_cph_cups_add_requesting_user_name (request, NULL);
+ escaped_printer_name = g_uri_escape_string (printer_name, NULL, FALSE);
g_snprintf (printer_uri, sizeof (printer_uri),
- "ipp://localhost/printers/%s", printer_name);
+ "ipp://localhost/printers/%s", escaped_printer_name);
+ g_free (escaped_printer_name);
/* new length: 1 + what we had before */
new_len = 1;