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

Adds name property for getJobs method #4

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

jcampbell05
Copy link

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.

@zdohnal
Copy link
Member

zdohnal commented Dec 6, 2017

Hi,
thank you for your effort with patch, but would you mind enhancing it? I'm missing some checks.

  1. 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).
  2. 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.

@jcampbell05
Copy link
Author

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 ?

@zdohnal
Copy link
Member

zdohnal commented Dec 7, 2017

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 )

@jcampbell05
Copy link
Author

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 :)

@zdohnal
Copy link
Member

zdohnal commented Mar 6, 2018

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...)?

@jcampbell05
Copy link
Author

:) sure will be happy to

@EToniolo
Copy link

EToniolo commented Sep 9, 2020

Hi, is there any news on this pull request? That's exactly what I need in my project.

@zdohnal
Copy link
Member

zdohnal commented Sep 9, 2020

@jcampbell05 Hi James,

do you intend to work on the PR?

@EToniolo if James is not interested, will you take over the PR?

@jcampbell05
Copy link
Author

Sorry I forgot about this PR - I'm happy for someone to help get this over the line

@jcampbell05
Copy link
Author

From what I can see we just need to do a squash to clean up the history and some unit tests written

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

Successfully merging this pull request may close these issues.

3 participants