Skip to content

Commit

Permalink
fix: properly validate google sheets url (#16683)
Browse files Browse the repository at this point in the history
* fix: properly validate google sheets url

* fix: check for spreadsheets in path

* fix(minor): error should throw if any of the cond fails

(cherry picked from commit e0c89cd)
  • Loading branch information
shadrak98 authored and mergify[bot] committed May 6, 2022
1 parent 6cb2955 commit f0d3a02
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frappe/utils/csvutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ def get_csv_content_from_google_sheets(url):


def validate_google_sheets_url(url):
if "docs.google.com/spreadsheets" not in url:
from urllib.parse import urlparse

u = urlparse(url)
if u.scheme != "https" or u.netloc != "docs.google.com" or "/spreadsheets/" not in u.path:
frappe.throw(
_('"{0}" is not a valid Google Sheets URL').format(url),
title=_("Invalid URL"),
Expand Down

0 comments on commit f0d3a02

Please sign in to comment.