From 0c17c70a15ed516809308a84c941eb033890b414 Mon Sep 17 00:00:00 2001 From: Mantaroh Yoshinaga Date: Fri, 13 Oct 2017 09:46:39 +0900 Subject: [PATCH] Bug 1185236 - Shorten print job name when GTK version is older than 3.18.2. r=karlt Since GTK 3.18.2, GTK allows setting job name with more than 255 bytes. As result, CUPS received the IPP error. (RFC 2911, Section 4.3.1) This patch will shorten print job name, if runtime GTK version is older than 3.18.2. MozReview-Commit-ID: EfB87Bvo6hX --HG-- extra : rebase_source : f502cd49b128aecce4d8268783377c46a63ad669 --- widget/gtk/nsDeviceContextSpecG.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/widget/gtk/nsDeviceContextSpecG.cpp b/widget/gtk/nsDeviceContextSpecG.cpp index f0de247407f0..93401134a11e 100644 --- a/widget/gtk/nsDeviceContextSpecG.cpp +++ b/widget/gtk/nsDeviceContextSpecG.cpp @@ -295,8 +295,14 @@ nsDeviceContextSpecGTK::BeginDocument(const nsAString& aTitle, const nsAString& aPrintToFileName, int32_t aStartPage, int32_t aEndPage) { - mTitle.Truncate(); - AppendUTF16toUTF8(aTitle, mTitle); + // Print job names exceeding 255 bytes are safe with GTK version 3.18.2 or + // newer. This is a workaround for old GTK. + if (gtk_check_version(3,18,2) != nullptr) { + PrintTarget::AdjustPrintJobNameForIPP(aTitle, mTitle); + } else { + CopyUTF16toUTF8(aTitle, mTitle); + } + return NS_OK; }