summaryrefslogtreecommitdiff
path: root/gtk/gtkprintoperation.c
diff options
context:
space:
mode:
authorFelipe Borges <felipeborges@gnome.org>2015-10-02 17:15:26 +0200
committerFelipe Borges <felipeborges@gnome.org>2015-10-09 10:51:26 +0200
commit70f577251ff3dff5b11b2040aee5aa3efe26da9d (patch)
treefe0fa79552ef33dd4ab907240c585818c41777ec /gtk/gtkprintoperation.c
parent5548665351c32a2fae4a1f7add079d8ce4131977 (diff)
downloadgtk+-70f577251ff3dff5b11b2040aee5aa3efe26da9d.tar.gz
gtkprintoperation: job names must not exceed 255 chars
According to http://datatracker.ietf.org/doc/rfc2911/, The 'name' attribute syntax is essentially the same as 'text', including the REQUIRED support of UTF-8 except that the sequence of characters is limited so that its encoded form MUST NOT exceed 255 (MAX) octets. CUPS will not print jobs with names exceeding 255 characters. https://bugzilla.gnome.org/show_bug.cgi?id=755988
Diffstat (limited to 'gtk/gtkprintoperation.c')
-rw-r--r--gtk/gtkprintoperation.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c
index 6dc7fb2403..9f4540b0f1 100644
--- a/gtk/gtkprintoperation.c
+++ b/gtk/gtkprintoperation.c
@@ -1606,6 +1606,7 @@ gtk_print_operation_set_job_name (GtkPrintOperation *op,
const gchar *job_name)
{
GtkPrintOperationPrivate *priv;
+ gchar *end;
g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
g_return_if_fail (job_name != NULL);
@@ -1613,7 +1614,25 @@ gtk_print_operation_set_job_name (GtkPrintOperation *op,
priv = op->priv;
g_free (priv->job_name);
- priv->job_name = g_strdup (job_name);
+ /*
+ * according to http://datatracker.ietf.org/doc/rfc2911/,
+ * job names MUST NOT exceed 255 (MAX) octets.
+ *
+ * CUPS will not print jobs with names exceeding 255 chars.
+ */
+ if (strlen (job_name) > 255)
+ {
+ end = g_utf8_find_prev_char (job_name, job_name + 255);
+ priv->job_name = g_utf8_substring (job_name,
+ 0,
+ g_utf8_pointer_to_offset (job_name,
+ end));
+ }
+ else
+ {
+ priv->job_name = g_strdup (job_name);
+ }
+
g_object_notify (G_OBJECT (op), "job-name");
}