Skip to content

Implement Custom Content-Disposition Header Parser to get rid of the CGI dependency #1088

New issue

Have a question about this project? Sign up for a free account to open an issue and contact its maintainers and the community.

By clicking “Sign up for ”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on ? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

mrDzurb
Copy link
Member

Description

This PR replaces the deprecated (in python 3.11) cgi.parse_header usage with a custom, pure-Python implementation for parsing Content-Disposition headers.

Tests

image

Usage

artifact_info = {"Content-Disposition": 'attachment; filename="example.txt"'}
_, file_name_info = parse_content_disposition(artifact_info["Content-Disposition"])
print("Parameters:", file_name_info)

artifact_info = {"Content-Disposition": "attachment; filename=example.txt"}
_, file_name_info = parse_content_disposition(artifact_info["Content-Disposition"])
print("Parameters:", file_name_info)

artifact_info = {"Content-Disposition": '  attachment ;  filename =   "example.txt" ; param = value  '}
disposition, file_name_info = parse_content_disposition(artifact_info["Content-Disposition"])
print("Parameters:", file_name_info)


artifact_info = {"Content-Disposition": None}
disposition, file_name_info = parse_content_disposition(artifact_info["Content-Disposition"])
print("Parameters:", file_name_info)

@oracle-contributor-agreementoracle-contributor-agreement bot added the OCA VerifiedAll contributors have signed the Oracle Contributor Agreement.label Feb 27, 2025
@mrDzurbmrDzurb requested a review from elizjo February 27, 2025 20:21
@github-actionsGitHub Actions
Copy link

-actions bot commented Feb 27, 2025

📌 Cov diff with main:

Coverage-94%

📌 Overall coverage:

Coverage-58.61%

@mrDzurbmrDzurb enabled auto-merge February 27, 2025 21:16
Copy link
Member

@elizjo elizjo left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for fixing this- was having issues with cgi dependency on Python 3.11.

@mrDzurbmrDzurb requested a review from lu-ohai February 27, 2025 22:03
@mrDzurbmrDzurb merged commit 4294649 into main Feb 27, 2025
19 checks passed
Sign up for free to join this conversation on . Already have an account? Sign in to comment
Labels
OCA VerifiedAll contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants