Skip to content

Commit

Permalink
Get rid of the "httptools" dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Mar 6, 2021
1 parent 58ef3a8 commit 10beb37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -6,6 +6,7 @@ Imagecast changelog
in progress
===========
- Add explicit ``--reload`` option to ``imagecast service`` for development mode
- Get rid of the "httptools" dependency


2020-06-08 0.3.0
Expand Down
6 changes: 3 additions & 3 deletions imagecast/api.py
Expand Up @@ -4,13 +4,13 @@
import logging
from typing import List
from dataclasses import dataclass
from urllib.parse import urlparse

from PIL import Image
from fastapi import FastAPI, Query, Depends, HTTPException
from fastapi.responses import Response, HTMLResponse, PlainTextResponse
from pydantic import BaseSettings
from starlette.status import HTTP_403_FORBIDDEN
from httptools.parser.parser import parse_url

from imagecast import __appname__, __version__
from imagecast.core import process
Expand Down Expand Up @@ -50,8 +50,8 @@ def index(options: QueryOptions = Depends(QueryOptions)):
if options.uri:

# Protect the service from accessing arbitrary remote URIs.
uri_parsed = parse_url(options.uri.encode('utf-8'))
remote_host = uri_parsed.host.decode()
uri_parsed = urlparse(options.uri.encode('utf-8'))
remote_host = uri_parsed.hostname.decode()
if '*' not in settings.allowed_hosts and remote_host not in settings.allowed_hosts:
raise HTTPException(status_code=HTTP_403_FORBIDDEN)

Expand Down

0 comments on commit 10beb37

Please sign in to comment.