Restrict browse from accessing local files

pull/690/head
onekum 2023-04-10 09:21:43 -04:00 committed by GitHub
parent 643ca9d084
commit fa8461be9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -11,6 +11,10 @@ def scrape_text(url):
if not url.startswith('http'):
return "Error: Invalid URL"
# Restrict access to local files
if url.startswith('file://') or url.startswith('file://localhost'):
return "Error: Access to local files is restricted"
try:
response = requests.get(url, headers=cfg.user_agent_header)
except requests.exceptions.RequestException as e:
@ -126,4 +130,4 @@ def summarize_text(text, question):
max_tokens=300,
)
return final_summary
return final_summary