Bug 1185236 - Shorten print job name when GTK version is older than 3.18.2. r?karlt draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Fri, 13 Oct 2017 15:48:39 +0900
changeset 679918 ed02278165f0f58de95c60e50b67e8f0faccff0e
parent 679917 9ae6eed7837bf3172d6967683683fc9e15a1064d
child 679919 4133e3da17fab26db657025cb8442c14f7553b26
push id84341
push usermantaroh@gmail.com
push dateFri, 13 Oct 2017 07:06:29 +0000
reviewerskarlt
bugs1185236
milestone58.0a1
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
widget/gtk/nsDeviceContextSpecG.cpp
--- a/widget/gtk/nsDeviceContextSpecG.cpp
+++ b/widget/gtk/nsDeviceContextSpecG.cpp
@@ -290,18 +290,24 @@ nsDeviceContextSpecGTK::EnumeratePrinter
                          nullptr, TRUE);
 }
 
 NS_IMETHODIMP
 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;
 }
 
 NS_IMETHODIMP nsDeviceContextSpecGTK::EndDocument()
 {
   if (mToPrinter) {
     // At this point, we might have a GtkPrinter set up in nsPrintSettingsGTK,
     // or we might not. In the single-process case, we probably will, as this