Comment 63 for bug 998156

TJ (tj) wrote :

I created a fix and tested it successfully:

Breakpoint 2, add_cups_options (key=0x7fe101636ca0 "cups-PageSize", value=0x7fe101636c80 "Custom.595.28x841.89",
    user_data=0x7fe1014c6970) at /home/all/SourceCode/gtk/gtk+3.0-3.4.2/./modules/printbackends/cups/gtkprintbackendcups.c:521
521 {
(gdb) c

Breakpoint 3, add_cups_options (key=0x7fe101636ca5 "PageSize", value=<optimized out>, user_data=<optimized out>)
    at /home/all/SourceCode/gtk/gtk+3.0-3.4.2/./modules/printbackends/cups/gtkprintbackendcups.c:566
566 if (custom_value && !g_str_has_prefix(value, "Custom."))
(gdb) n
573 gtk_cups_request_encode_option (request, key, value);
(gdb) c

The fix simply checks whether the value already has the "Custom." prefix and if so, doesn't insert it again. In the code above the test !g_str_has_prefix(value, "Custom.") fails and processing goes through the 'else' clause on line 573.

- /* Add "Custom." prefix to custom values. */
- if (custom_value)
+ /* Add "Custom." prefix to custom values (if they don't already have the prefix). */
+ if (custom_value && !g_str_has_prefix(value, "Custom."))

A debdiff (for Precise) is attached.