Skip to content

Conversation

@safiya2610
Copy link
Contributor

@safiya2610 safiya2610 commented Dec 24, 2025

Summary
Updated validatePictureUrl to support Google Drive links alongside standard image URLs.

Key Changes
Google Drive Integration: Added validation for /file/d/, open?id=, and uc?id= patterns.
Image Extensions: Maintained support for jpg, png, webp, svg, and gif.
Security: Blocked Base64/Data URIs to prevent large string uploads.
Reliability: Added try...catch with new URL() to handle malformed inputs gracefully.

Test Cases
Pass: Direct image URLs and Google Drive share links.

  1. High Compatibility
    Google Drive provides different types of links depending on how a user clicks "Share." By including all three, you ensure the user doesn't get a frustrating "Invalid URL" error just because they copied the link from a different menu:
    /file/d/ID/view: The standard "Share" link most users copy.
    open?id=ID: The older legacy sharing format.
    uc?id=ID: The "Universal Content" link used for direct downloads and embedding.

  2. Prevents "False Positives"
    If you simply allowed any URL containing drive.google.com, a user could paste a link to a Google Drive Folder or the Drive Homepage. Your code ensures that only links pointing to individual files are accepted.

Fixes #6986

Refactor validatePictureUrl function to improve URL validation and error handling for image URLs and Google Drive links.

Signed-off-by: Safiya <[email protected]>
@safiya2610
Copy link
Contributor Author

@kishore007k @leecalcote Please review the PR.


// Block base64 / data URIs
if (value.startsWith("data:")) {
return "Data URIs are not allowed. Please provide an image URL or Google Drive link.";
Copy link
Member

Choose a reason for hiding this comment

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

Let's not callout Google Drive, specifically.

"Data URI" is not user-friendly language either.

We simply need to state that a hyperlink to an image is what is required.

"png",
"webp",
"svg",
"gif"
Copy link
Member

Choose a reason for hiding this comment

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

What about avif?

Copy link
Member

@leecalcote leecalcote left a comment

Choose a reason for hiding this comment

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

I don't know that all of this validation is helpful, but is perhaps, more hurtful than anything else.

Do we need validation... at all? If so, the lighter, the better.

@leecalcote
Copy link
Member

@safiya2610 why are you not reviewing the other open PR on this topic?

@leecalcote leecalcote added the issue/duplicate This issue or pull request already exists label Dec 24, 2025
Updated allowed image extensions to include 'avif'.

Signed-off-by: Safiya <[email protected]>
@safiya2610
Copy link
Contributor Author

Thanks for the feedback, @leecalcote
To make this as 'light' as possible: would you prefer if I remove the file extension and Google Drive logic entirely and only check if the input is a valid URL (starting with http/https)?

@safiya2610
Copy link
Contributor Author

@safiya2610 why are you not reviewing the other open PR on this topic?

surely I would take care of it.

@l5io
Copy link
Contributor

l5io commented Dec 24, 2025

🚀 Preview for commit c69a476 at: https://694c21c40fcc296b5bee13b3--layer5.netlify.app

@safiya2610
Copy link
Contributor Author

@leecalcote I’ve updated the validation logic so that all valid URLs are accepted, including Drive and other hosted links. also keep it very simple and light.

@l5io
Copy link
Contributor

l5io commented Dec 24, 2025

🚀 Preview for commit 985cae8 at: https://694c26f687b1ccb24b21826e--layer5.netlify.app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

issue/duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Profile picture URL validation rejects valid image links from Google Drive

3 participants