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

Sanitize flagging inputs before writing to csv #817

Merged
merged 4 commits into from Mar 14, 2022
Merged

Sanitize flagging inputs before writing to csv #817

merged 4 commits into from Mar 14, 2022

Conversation

abidlabs
Copy link
Member

To prevent csv injection, this sanitizes flagging inputs before writing to the csv

gradio/utils.py Outdated
return data
elif isinstance(data, list) and isinstance(data[0], str):
sanitized_data = copy.deepcopy(data)
for i, item in enumerate(data):
Copy link
Contributor

Choose a reason for hiding this comment

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

better to use index instead of i

gradio/utils.py Outdated

if isinstance(data, str):
if data.startswith(unsafe_prefixes):
warnings.warn("Sanitizing flagged data by escaping cell contents")
Copy link
Contributor

Choose a reason for hiding this comment

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

might be nice to inform user about unsafe_prefixes

@FarukOzderim
Copy link
Contributor

LGTM other than the points above, great work as always!

@abidlabs
Copy link
Member Author

Awesome, thanks for the helpful suggestions

Former-commit-id: 581f2c2
@abidlabs
Copy link
Member Author

I'll hold off on merging until we resolve the big file issue

@abidlabs abidlabs merged commit 80fea89 into master Mar 14, 2022
2 checks passed
@abidlabs abidlabs deleted the csv-sec branch March 14, 2022 20:46
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.

None yet

2 participants