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

Improve validation for image uploads. #2394

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jpd236
Copy link
Contributor

@jpd236 jpd236 commented Jan 5, 2025

The Google App Script insertImage API only appears to support GIF/PNG/JPG images. Attempts to upload other formats (e.g. webp) fail with an internal error.

For uploads, indicate that these are the only accepted file extensions. Clients often treat this as a suggestion rather than a hard requirement if someone is particularly certain that a file will work despite the extension being different.

For links, make a HEAD request for the image and inspect the Content-Type in the response headers. Fail open in cases where we can't definitively determine the Content-Type.

Note that copy-pasting images via the keyboard shortcut works and supports other formats, so this is probably a simpler approach to take in most cases.

See #2285

The Google App Script insertImage API only appears to support
GIF/PNG/JPG images. Attempts to upload other formats (e.g. webp) fail
with an internal error.

For uploads, indicate that these are the only accepted file extensions.
Clients often treat this as a suggestion rather than a hard requirement
if someone is particularly certain that a file will work despite the
extension being different.

For links, make a HEAD request for the image and inspect the
Content-Type in the response headers. Fail open in cases where we can't
definitively determine the Content-Type.

Note that copy-pasting images via the keyboard shortcut works and
supports other formats, so this is probably a simpler approach to take
in most cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant