-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fixes SVG Icons #9765
Fixes SVG Icons #9765
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-pypi-previews.s3.amazonaws.com/0aad8d21ea3b92a7e4257a1c31a9ba89845572e7/gradio-5.1.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@0aad8d21ea3b92a7e4257a1c31a9ba89845572e7#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-npm-previews.s3.amazonaws.com/0aad8d21ea3b92a7e4257a1c31a9ba89845572e7/gradio-client-1.7.0.tgz Use Lite from this PR <script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/0aad8d21ea3b92a7e4257a1c31a9ba89845572e7/dist/lite.js""></script> |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
|
Could we just treat the gradio/gradio/components/chatbot.py Line 281 in 39a0e8c
|
I think button icons are already processed via |
Could we check if a file was specified before the app was running, in which case serve the file inline? I think that would be a better, more general fix |
I don't follow. That's what I'm doing but only if the file is an svg. We could remove the svg mimetype check from this PR but I wanted to modify the file serving logic as little as possible for security reasons (I'm paranoid now) hehe |
Thanks @freddyaboulton this indeed works, but I think there's a more efficient way, which is to not move such files to the cache altogether. Currently, inside the Component constructor --> Instead, I'd suggest that we just mark svgs as safe directly in the Component constructor --> Otherwise, this looks great. If possible, it'd be great to turn your demo into a test to ensure that arbitrary svgs are not marked as allowed after the app is running |
This is not ready right @freddyaboulton? You don't do the check to see if its running or not anymore. e.g. In your original example import gradio as gr
with gr.Blocks() as demo:
button = gr.Button("button", icon="clean.svg")
button.click(lambda: gr.Button("button", icon="arrow.svg"), None, button)
demo.launch() The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the above needs to be fixed for security reasons
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm thanks so much @freddyaboulton!
Thank you @abidlabs!! |
Description
Closes: #9587
SVG icons could not be displayed because the backend would return them with
content_disposition_type="attachment"
. Developers could not set them inallowed_paths
because they get moved to the cache and so the actual path fetched by the client is different to what the developer would know.My proposed fix is to mark svg files moved to the cache before the app is running as "allowed" since they are developer supplied paths.
You can run this demo to verify that arbitrary svgs are not marked as allowed after the app is running
🎯 PRs Should Target Issues
Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.
Not adhering to this guideline will result in the PR being closed.
Tests
PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests:
bash scripts/run_all_tests.sh
You may need to run the linters:
bash scripts/format_backend.sh
andbash scripts/format_frontend.sh