Skip to content

Conversation

mrDzurb
Copy link
Member

@mrDzurb mrDzurb commented Feb 27, 2025

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-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Feb 27, 2025
@mrDzurb mrDzurb requested a review from elizjo February 27, 2025 20:21
Copy link

📌 Cov diff with main:

Coverage-94%

📌 Overall coverage:

Coverage-58.61%

@mrDzurb mrDzurb 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.

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

Successfully merging this pull request may close these issues.

4 participants