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

Unsupported filetype for valid image using geturl.php #108

Closed
dessalines opened this issue Feb 27, 2020 · 8 comments
Closed

Unsupported filetype for valid image using geturl.php #108

dessalines opened this issue Feb 27, 2020 · 8 comments

Comments

@dessalines
Copy link
Contributor

Could you help me test this seemingly valid image with geturl.php?

https://MY_PICTSHARE.com/pictshare/api/geturl.php?url=https://i.guim.co.uk/img/media/4d908693e566fdd7f8cdeac559f6375b739887a3/356_37_3264_1958/master/3264.jpg?width=1200&height=630&quality=85&auto=format&fit=crop&overlay-align=bottom%2Cleft&overlay-width=100p&overlay-base64=L2ltZy9zdGF0aWMvb3ZlcmxheXMvdGctZGVmYXVsdC5wbmc&enable=upscale&s=3a70177dcc60673c606302d96fcbd9bc

Error:

filetype: "x-empty"
reason: "Unsupported filetype"
status: "err"

@geek-at
Copy link
Member

geek-at commented Feb 27, 2020

are you using the docker container or did you install it yourself?

If it's the latter it looks like you're missing some libraries.. does the server have the file command?

@dessalines
Copy link
Contributor Author

dessalines commented Feb 28, 2020

Its using shtripok's docker (necessary for arm compatibility too I think). My docker-compose.yml section:

  pictshare:
    image: shtripok/pictshare:latest
    ports:
      - "127.0.0.1:8537:80"
    volumes:
      - pictshare:/usr/share/nginx/html/data
    restart: always

Did you test this one out?

edit: I also forgot to mention, that most urls work, its just some don't.

@geek-at
Copy link
Member

geek-at commented Feb 28, 2020

Actually the latest official docker images detect the architecture and should work on ARM without a problem

But it seems that the site you're using is checking some sessions or something because when I open your image in the browser it works

But when I download it with curl

curl "https://i.guim.co.uk/img/media/4d908693e566fdd7f8cdeac559f6375b739887a3/356_37_3264_1958/master/3264.jpg?width=1200&height=630&quality=85&auto=format&fit=crop&overlay-align=bottom%2Cleft&overlay-width=100p&overlay-base64=L2ltZy9zdGF0aWMvb3ZlcmxheXMvdGctZGVmYXVsdC5wbmc&enable=upscale&s=3a70177dcc60673c606302d96fcbd9bc"

It's answering with

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>401 Unauthorized - missing signature</title>
  </head>
  <body>
    <h1>Error 401 Unauthorized - missing signature</h1>
    <p>Unauthorized - missing signature</p>
    <h3>Guru Mediation:</h3>
    <p>Details: cache-vie21641-VIE 1582891201 3100362804</p>
    <hr>
    <p>Varnish cache server</p>
  </body>
</html>

So it's not a problem with Pictshare, it's the caching server that required some headers probably

@dessalines
Copy link
Contributor Author

Hrm this is strange... when I run that exact same curl command on my local machine, it does download the picture fine. What curl you on?

curl --version
curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh2/1.9.0 nghttp2/1.39.2

@geek-at
Copy link
Member

geek-at commented Feb 28, 2020

Sorry I copied the link after I put it in my browser.

when you curl with the original link you posted

curl "https://i.guim.co.uk/img/media/4d908693e566fdd7f8cdeac559f6375b739887a3/356_37_3264_1958/master/3264.jpg\?width\=1200\&height\=630\&quality\=85\&auto\=format\&fit\=crop\&overlay-align\=bottom%2Cleft\&overlay-width\=100p\&overlay-base64\=L2ltZy9zdGF0aWMvb3ZlcmxheXMvdGctZGVmYXVsdC5wbmc\&enable\=upscale\&s\=3a70177dcc60673c606302d96fcbd9bc"

You'll get the error. It seems one of the variables attached to the image is a session ID that's not available for long

@dessalines
Copy link
Contributor Author

That one is different than the link I posted at the top, it seems to have a lot of extra slashes.

This command is correctly downloading the image: curl "https://i.guim.co.uk/img/media/4d908693e566fdd7f8cdeac559f6375b739887a3/356_37_3264_1958/master/3264.jpg?width=1200&height=630&quality=85&auto=format&fit=crop&overlay-align=bottom%2Cleft&overlay-width=100p&overlay-base64=L2ltZy9zdGF0aWMvb3ZlcmxheXMvdGctZGVmYXVsdC5wbmc&enable=upscale&s=3a70177dcc60673c606302d96fcbd9bc" -o test_img

@geek-at
Copy link
Member

geek-at commented Mar 6, 2020

Did you rawurlencode the URL before attaching it to https://MY_PICTSHARE.com/pictshare/api/geturl.php?url= ? because that url has "&" and "?" in it so if you use

https://MY_PICTSHARE.com/pictshare/api/geturl.php?url=https://i.guim.co.uk/img/media/4d908693e566fdd7f8cdeac559f6375b739887a3/356_37_3264_1958/master/3264.jpg?width=1200&height=630&quality=85&auto=format&fit=crop&overlay-align=bottom%2Cleft&overlay-width=100p&overlay-base64=L2ltZy9zdGF0aWMvb3ZlcmxheXMvdGctZGVmYXVsdC5wbmc&enable=upscale&s=3a70177dcc60673c606302d96fcbd9bc

Pictshare would only see url=https://i.guim.co.uk/img/media/4d908693e566fdd7f8cdeac559f6375b739887a3/356_37_3264_1958/master/3264.jpg which will return an invalid image.

if you rawurlencode it to https%3A%2F%2Fi.guim.co.uk%2Fimg%2Fmedia%2F4d908693e566fdd7f8cdeac559f6375b739887a3%2F356_37_3264_1958%2Fmaster%2F3264.jpg%3Fwidth%3D1200%26height%3D630%26quality%3D85%26auto%3Dformat%26fit%3Dcrop%26overlay-align%3Dbottom%252Cleft%26overlay-width%3D100p%26overlay-base64%3DL2ltZy9zdGF0aWMvb3ZlcmxheXMvdGctZGVmYXVsdC5wbmc%26enable%3Dupscale%26s%3D3a70177dcc60673c606302d96fcbd9bc

and attach it encoded to the api, it works on my end

https://MY_PICTSHARE.com/pictshare/api/geturl.php?url=https%3A%2F%2Fi.guim.co.uk%2Fimg%2Fmedia%2F4d908693e566fdd7f8cdeac559f6375b739887a3%2F356_37_3264_1958%2Fmaster%2F3264.jpg%3Fwidth%3D1200%26height%3D630%26quality%3D85%26auto%3Dformat%26fit%3Dcrop%26overlay-align%3Dbottom%252Cleft%26overlay-width%3D100p%26overlay-base64%3DL2ltZy9zdGF0aWMvb3ZlcmxheXMvdGctZGVmYXVsdC5wbmc%26enable%3Dupscale%26s%3D3a70177dcc60673c606302d96fcbd9bc

returns

{
  "status": "ok",
  "hash": "o5x75s.jpg",
  "url": "https://pictshare.net/o5x75s.jpg",
  "filetype": "jpeg",
  "delete_code": "z11o0dyzgwdg6oqz08zrx4h18d0vvw",
  "delete_url": "https://pictshare.net/delete_z11yzgwdg6oqz08zigrx4h18d0vvw/o5x75s.jpg"
}

@dessalines
Copy link
Contributor Author

That did it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants