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

Add the ignore_mdc_error flag setter and getter #180

Merged
merged 2 commits into from
Jan 23, 2024

Conversation

Verseth
Copy link
Contributor

@Verseth Verseth commented Dec 8, 2023

This fixes #141.

I added a setter and getter for the ignore-mdc-error flag.

  • GPGME::Ctx#ignore_mdc_error
  • GPGME::Ctx#ignore_mdc_error=

Example usage:

ctx = GPGME::Ctx.new
ctx.ignore_mdc_error #=> false

ctx.ignore_mdc_error = true
ctx.ignore_mdc_error #=> true

ctx = GPGME::Ctx.new(ignore_mdc_error: true)
ctx.ignore_mdc_error #=> true

I also added a generic pair of getter/setter methods that can be used to set ctx flags that have not been exposed through getters and setters in Ruby.

  • GPGME::Ctx#get_ctx_flag
  • GPGME::Ctx#set_ctx_flag

Example usage:

ctx = GPGME::Ctx.new
ctx.get_ctx_flag("ignore-mdc-error") #=> ""

ctx.ignore_mdc_error = true
ctx.ignore_mdc_error #=> true
ctx.get_ctx_flag("ignore-mdc-error") #=> "1"

ctx.set_ctx_flag("ignore-mdc-error", "0")
ctx.ignore_mdc_error #=> false
ctx.get_ctx_flag("ignore-mdc-error") #=> ""

ctx.set_ctx_flag("ignore-mdc-error", "1")
ctx.ignore_mdc_error #=> true
ctx.get_ctx_flag("ignore-mdc-error") #=> "1"

These two methods make it possible to use features that are available in GPGME but haven't been defined in the Ruby bindings, like the ignore-mdc-error flag prior to this PR.

Add generic `get_ctx_flag` getter and `set_ctx_flag` setter
Copy link
Owner

@ueno ueno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me; thank you for also adding the tests!

@ueno ueno merged commit 7d6dc97 into ueno:master Jan 23, 2024
4 checks passed
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.

GPGME::Error::DecryptFailed presumably for message without integrity protection
2 participants