[LOW] STR #4153: <DefaultPrinter> tag in printers.conf closes with </Printer>

Dominic Cleal <[email protected]>
Newsgroups gmane.comp.printing.cups.bugs
Message-ID <[email protected]>
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

While testing support for parsing printers.conf in Augeas
(http://augeas.net, a configuration API), it was found the
<DefaultPrinter> section is closed with </Printer> rather than the more
obvious </DefaultPrinter>.  The Augeas lens was expecting a matching set
of tags so failed to parse.

While this is an issue with Augeas (though not an easy one to fix), it
seems this could be a common trap and it improved by using
</DefaultPrinter> to match HTML, XML and Apache HTTP type config files.

Attached is a patch to change this, preserving compatibility to read old
printers.conf files.  It's untested, but compiles with trunk.

Link: http://www.cups.org/str.php?L4153
Version: 1.6-current

_______________________________________________
cups-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/cups-bugs
r10562_defaultprinter.patch (text/plain, 1.6 KB)
Index: doc/help/ref-printers-conf.html
===================================================================
--- doc/help/ref-printers-conf.html	(revision 10563)
+++ doc/help/ref-printers-conf.html	(working copy)
@@ -90,7 +90,7 @@
 <PRE CLASS="command">
 &lt;DefaultPrinter name&gt;
   ...
-&lt;/Printer&gt;
+&lt;/DefaultPrinter&gt;
 </PRE>
 
 <H3>Description</H3>
Index: man/printers.conf.man
===================================================================
--- man/printers.conf.man	(revision 10563)
+++ man/printers.conf.man	(working copy)
@@ -29,7 +29,7 @@
 .br
 Defines a specific printer.
 .TP 5
-<DefaultPrinter name> ... </Printer>
+<DefaultPrinter name> ... </DefaultPrinter>
 .br
 Defines a default printer.
 .TP 5
Index: scheduler/printers.c
===================================================================
--- scheduler/printers.c	(revision 10563)
+++ scheduler/printers.c	(working copy)
@@ -957,7 +957,8 @@
         cupsdLogMessage(CUPSD_LOG_ERROR,
 	                "Syntax error on line %d of printers.conf.", linenum);
     }
-    else if (!_cups_strcasecmp(line, "</Printer>"))
+    else if (!_cups_strcasecmp(line, "</Printer>") ||
+             !_cups_strcasecmp(line, "</DefaultPrinter"))
     {
       if (p != NULL)
       {
@@ -1656,7 +1657,10 @@
       cupsFilePrintf(fp, "Attribute marker-change-time %ld\n",
                      (long)printer->marker_time);
 
-    cupsFilePuts(fp, "</Printer>\n");
+    if (printer == DefaultPrinter)
+      cupsFilePrintf(fp, "</DefaultPrinter>\n");
+    else
+      cupsFilePrintf(fp, "</Printer>\n");
 
 #ifdef __sgi
     /*
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.