Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect character encoding #1958

Closed
michaelrsweet opened this issue Sep 5, 2006 · 3 comments
Closed

Incorrect character encoding #1958

michaelrsweet opened this issue Sep 5, 2006 · 3 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.2-current
CUPS.org User: jerome.alet

Mike said that in CUPS 1.2.x and higher, job's title and filename were always encoded in UTF-8 :
http://www.cups.org/newsgroups.php?s10031+gcups.general+v10038+T0

It seems it's not the case at least with CUPS 1.2.1 : the title
passed on the backend's command line is NOT encoded in UTF-8.

I printed using the lp command from an xterm, with a French locale using
the ISO-8859-15 charset.

The backend's command line received the title as I typed it in my
xterm as the argument to lp's -t command line option.

If I look at a dump of CUPS' /var/spool/cups/c00501 file, I've got
the confirmation :

attributes-charset : utf-8
attributes-natural-language : fr-fr@euro
job-name : ab�c�daire
           (ISO-8859-15 equivalent to abécédaire)

Could each string coming from the end user be converted into UTF-8 (title, filename...) or made consitent with the attributes-charset ?

Should the filename conversion occur or not ? Couldn't this break some filters and/or backends when printing in raw mode ?

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Need to add a _cupsTranscodeArgs() function to convert the argv[] array from the locale encoding to UTF-8.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet
Copy link
Collaborator Author

"str1958.patch":

Index: berkeley/lpc.c

--- berkeley/lpc.c (revision 5922)
+++ berkeley/lpc.c (working copy)
@@ -65,7 +65,7 @@
params; / Pointer to parameters */

  • _cupsSetLocale();
  • _cupsSetLocale(argv);

/*

  • Connect to the scheduler...
    Index: berkeley/lprm.c

    --- berkeley/lprm.c (revision 5922)
    +++ berkeley/lprm.c (working copy)
    @@ -61,7 +61,7 @@
    http_encryption_t encryption; /* Encryption? */
  • _cupsSetLocale();
  • _cupsSetLocale(argv);

/*

  • Setup to cancel individual print jobs...
    Index: berkeley/lpq.c

    --- berkeley/lpq.c (revision 5922)
    +++ berkeley/lpq.c (working copy)
    @@ -78,7 +78,7 @@
    cups_dest_t dests; / Destinations */
  • _cupsSetLocale();
  • _cupsSetLocale(argv);

/*

  • Check for command-line options...
    Index: berkeley/lpr.c

    --- berkeley/lpr.c (revision 5922)
    +++ berkeley/lpr.c (working copy)
    @@ -93,7 +93,7 @@
    #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
  • _cupsSetLocale();
  • _cupsSetLocale(argv);

deletefile = 0;
printer = NULL;

Index: systemv/cupstestppd.c

--- systemv/cupstestppd.c (revision 5922)
+++ systemv/cupstestppd.c (working copy)
@@ -113,7 +113,7 @@
"JCL", "PAGE", "PROLOG" };

  • _cupsSetLocale();
  • _cupsSetLocale(argv);

/*

  • Display PPD files for each file listed on the command-line...
    Index: systemv/accept.c

    --- systemv/accept.c (revision 5922)
    +++ systemv/accept.c (working copy)
    @@ -58,7 +58,7 @@
    int cancel; /* Cancel jobs? */
  • _cupsSetLocale();
  • _cupsSetLocale(argv);

/*

  • See what operation we're supposed to do...
    Index: systemv/lpmove.c

    --- systemv/lpmove.c (revision 5922)
    +++ systemv/lpmove.c (working copy)
    @@ -66,7 +66,7 @@
    dest; / New destination */
  • _cupsSetLocale();
  • _cupsSetLocale(argv);

dest = NULL;
dests = NULL;

Index: systemv/cupstestdsc.c

--- systemv/cupstestdsc.c (revision 5922)
+++ systemv/cupstestdsc.c (working copy)
@@ -65,7 +65,7 @@
int num_files; /* Number of files tested */

  • _cupsSetLocale();
  • _cupsSetLocale(argv);

/*

  • Collect command-line arguments...
    Index: systemv/lpadmin.c

    --- systemv/lpadmin.c (revision 5922)
    +++ systemv/lpadmin.c (working copy)
    @@ -92,7 +92,7 @@
    cups_option_t options; / Options */
  • _cupsSetLocale();
  • _cupsSetLocale(argv);

http = NULL;
printer = NULL;

Index: systemv/cancel.c

--- systemv/cancel.c (revision 5922)
+++ systemv/cancel.c (working copy)
@@ -60,7 +60,7 @@
ipp_op_t op; /* Operation */

  • _cupsSetLocale();
  • _cupsSetLocale(argv);

/*

  • Setup to cancel individual print jobs...
    Index: systemv/cupsaddsmb.c

    --- systemv/cupsaddsmb.c (revision 5922)
    +++ systemv/cupsaddsmb.c (working copy)
    @@ -78,7 +78,7 @@
    cups_dest_t dests; / Printers */
  • _cupsSetLocale();
  • _cupsSetLocale(argv);

/*

  • Parse command-line arguments...
    Index: systemv/lpinfo.c

    --- systemv/lpinfo.c (revision 5922)
    +++ systemv/lpinfo.c (working copy)
    @@ -62,7 +62,7 @@
    int long_status; /* Long listing? */
  • _cupsSetLocale();
  • _cupsSetLocale(argv);

http = NULL;
long_status = 0;

Index: systemv/lpoptions.c

--- systemv/lpoptions.c (revision 5922)
+++ systemv/lpoptions.c (working copy)
@@ -69,7 +69,7 @@
option; / Current option */

  • _cupsSetLocale();
  • _cupsSetLocale(argv);

/*

  • Loop through the command-line arguments...
    Index: systemv/lpstat.c

    --- systemv/lpstat.c (revision 5922)
    +++ systemv/lpstat.c (working copy)
    @@ -85,7 +85,7 @@
    char op; /* Last operation on command-line */
  • _cupsSetLocale();
  • _cupsSetLocale(argv);

/*

  • Parse command-line options...
    Index: systemv/lp.c

    --- systemv/lp.c (revision 5922)
    +++ systemv/lp.c (working copy)
    @@ -117,7 +117,7 @@
    return (0);
    #endif /* __sun */
  • _cupsSetLocale();
  • _cupsSetLocale(argv);

silent = 0;
printer = NULL;

Index: systemv/lppasswd.c

--- systemv/lppasswd.c (revision 5922)
+++ systemv/lppasswd.c (working copy)
@@ -102,7 +102,7 @@
#endif /* HAVE_SIGACTION && !HAVE_SIGSET*/

  • _cupsSetLocale();
  • _cupsSetLocale(argv);

/*

  • Check to see if stdin, stdout, and stderr are still open...
    Index: cups/langprintf.c

    --- cups/langprintf.c (revision 5922)
    +++ cups/langprintf.c (working copy)
    @@ -28,7 +28,7 @@
    *

  • _cupsLangPrintf() - Print a formatted message string to a file.

  • _cupsLangPuts() - Print a static message string to a file.

  • * _cupsSetLocale() - Set the current locale.

    • _cupsSetLocale() - Set the current locale and transcode the command-line.
      */

    /*
    @@ -140,15 +140,18 @@

    /*

  • * '_cupsSetLocale()' - Set the current locale.

    • '_cupsSetLocale()' - Set the current locale and transcode the command-line.
      */

    void
    -_cupsSetLocale(void)
    +_cupsSetLocale(char argv[]) / IO - Command-line arguments */
    {

  • int i; /* Looping var */

  • char buffer[8192]; /* Command-line argument buffer */

  • _cups_globals_t cg; / Global data */
    #ifdef LC_TIME

  • const char lc_time; / Current LC_TIME value */

  • char new_lc_time[255], /* New LC_TIME value */

  • const char lc_time; / Current LC_TIME value */

  • char new_lc_time[255], /* New LC_TIME value /
    *charset; /
    Pointer to character set /
    #endif /
    LC_TIME */

@@ -181,6 +184,42 @@

setlocale(LC_TIME, new_lc_time);
#endif /* LC_TIME */
+

  • /*
  • * Initialize the default language info...
  • */
  • cg = _cupsGlobals();
  • if (!cg->lang_default)
  • cg->lang_default = cupsLangDefault();
  • /*
  • * Transcode the command-line arguments from the locale charset to
  • * UTF-8...
  • */
  • if (cg->lang_default->encoding != CUPS_US_ASCII &&
  •  cg->lang_default->encoding != CUPS_UTF8)
    
  • {
  • for (i = 1; argv[i]; i ++)
  • {
  • /*
    
  •  \* Try converting from the locale charset to UTF-8...
    
  •  */
    
  •  if (cupsCharsetToUTF8((cups_utf8_t *)buffer, argv[i], sizeof(buffer),
    
  •                        cg->lang_default->encoding) < 0)
    
  •    continue;
    
  • /*
    
  •  \* Save the new string if it differs from the original...
    
  •  */
    
  •  if (strcmp(buffer, argv[i]))
    
  •    argv[i] = strdup(buffer);
    
  • }
  • }
    }

Index: cups/i18n.h

--- cups/i18n.h (revision 5922)
+++ cups/i18n.h (working copy)
@@ -105,7 +105,7 @@
extern void _cupsMessageFree(cups_array_t *a);
extern cups_array_t *_cupsMessageLoad(const char *filename);
extern const char *_cupsMessageLookup(cups_array_t *a, const char *m);
-extern void _cupsSetLocale(void);
+extern void _cupsSetLocale(char *argv[]);

ifdef __cplusplus

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant