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

The schedulers mime.types parser gets it wrong sometimes #3059

Closed
michaelrsweet opened this issue Jan 11, 2009 · 3 comments
Closed

The schedulers mime.types parser gets it wrong sometimes #3059

michaelrsweet opened this issue Jan 11, 2009 · 3 comments

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.3-current
CUPS.org User: opher

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 theif'. Please also note that in the "truth" block current->prev->prev is never referenced.

Patch attached.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet
Copy link
Collaborator Author

"add-type-rule-fix.patch":

This patch file was generated by NetBeans IDE

Following Index: paths are relative to: H:\My Documents\Projects\CUPS\cups-1.3.x\scheduler

This patch can be applied using context Tools: Patch action on respective folder.

It uses platform neutral UTF-8 encoding and \n newlines.

Above lines and this line are ignored by the patching process.

Index: type.c
--- type.c Base (BASE)
+++ type.c Locally Modified (Based On LOCAL)
@@ -187,8 +187,7 @@
else if (*rule == '+' && current != NULL)
{
if (logic != MIME_MAGIC_AND &&

  •      current != NULL && current->prev != NULL &&
    
  • current->prev->prev != NULL)
    
  •      current != NULL && current->prev != NULL)
    
    {
    /*
    * OK, we have more than 1 rule in the current tree level... Make a

@michaelrsweet
Copy link
Collaborator Author

"str3059.patch":

Index: CHANGES-1.3.txt

--- CHANGES-1.3.txt (revision 8239)
+++ CHANGES-1.3.txt (working copy)
@@ -5,6 +5,8 @@

- Documentation fixes (STR #2994, STR #2995, STR #3008, STR #3056,
  STR #3057)
    • The scheduler did not always load MIME type rules correctly
  • (STR #3059)
    
  •      current != NULL && current->prev != NULL &&
    
  • current->prev->prev != NULL)
    
  •      current != NULL && current->prev != NULL)
    
    {
    /*
    * OK, we have more than 1 rule in the current tree level... Make a

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