Adds name property for getJobs method
In original cups documentation they allow you to specify a name to view the queue of a printer, pycups only allows you originally to see jobs across all queues. I've now exposed an extra name kwarg which if specified with the name of a printer will filter it to the jobs of that printer.
Hi, thank you for your effort with patch, but would you mind enhancing it? I'm missing some checks.
- Code creates static array of char for uri, but it doesn't check if string+name is longer than 1024 - if it is, correct it (like calling debugprintf with message about for example "name is too long, cutting it" and cut the name to correct length).
- Code doesn't check if 'name' doesn't contain any reserved characters (except for /)
I know these checks can be done in sw using python-cups and they aren't used in other parts of code, but IMO it is good habit to think about all situations, which can happen.
I've implemented number 1.
I'm not sure how to do number 2, I'm trying to find a good URI validation method. Maybe you could point me in the right direction ?
Ad1) still missing recovering from the issue - cutting 'name' string to be able to get in 'uri' array. This way the bigger string will still overwrite memory behind of memory reserved for 'uri' array -> which can be security issue. Ad2) I think the easiest way is try to find these reserved characters in 'name' string by strchr or by regex.h - reserved characters in URI ( https://tools.ietf.org/html/rfc2396#section-2.2 - only '/' can be in printers uri in 'name' variable according https://tools.ietf.org/html/rfc3510#section-4.6.1 )
Okay added some validation to make sure its not a reserved character. Not sure how we should handle regex failing to compile so maybe you can help point me in right direction.
I now added name trimming (I also moved the debug message to the correct method). Please can you check I'm doing the correct calculations when trimming as I'm not as familiar with manipulating strings in C :)
Looks good - I'll make some tests. Would you mind cleaning up your commits (there are some things which shoudln't be there - like .so files, typos...)?
:) sure will be happy to
Hi, is there any news on this pull request? That's exactly what I need in my project.
@jcampbell05 Hi James,
do you intend to work on the PR?
@EToniolo if James is not interested, will you take over the PR?
Sorry I forgot about this PR - I'm happy for someone to help get this over the line
From what I can see we just need to do a squash to clean up the history and some unit tests written