[cups.bugs] [MOD] STR #3059: The schedulers mime.types parser gets it wrong sometimes
Opher Shachar
ophers at ladpc.co.il
Sun Jan 11 14:59:11 PST 2009
DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
The function mimeAddTypeRule() in scheduler/type.c parses some rules wrong.
This happens for example to:
application/x-shell
Try this:
----------- foo.sh start --------------
echo "Hello, World!"
---------------------------------------
----------- foo.bash start ------------
#!/bin/bash
echo "Hello, World!"
---------------------------------------
(1) lp -d printer foo.sh
(2) lp -d printer foo.bash
Both result in the scheduler auto-typing as text/plain.
This happens because of a wrong `if' at line 189.
At the point when we reach the (first) `+' in:
application/x-shell sh printable(0,1024) + string(0,#!)
We have:
logic == MIME_MAGIC_OR
current != NULL
current->prev != NULL
current->prev->prev == NULL
and so the `if' expression evaluates to FALSE and we end up executing this
block (line 215):
current->parent->op = MIME_MAGIC_AND;
which ends up evaluating the rule as: sh + printable(0,1024) + ...
The fix is to drop the `current->prev->prev != NULL' evaluation from the
`if'. Please also note that in the "truth" block current->prev->prev is
never referenced.
Patch attached.
Link: http://www.cups.org/str.php?L3059
Version: 1.3-current
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: add-type-rule-fix.patch
URL: <https://lists.cups.org/pipermail/cups/attachments/20090111/c970f695/attachment.ksh>
More information about the cups
mailing list