Yannis4444 / Orange-Share

A small python server that accepts requests from an Apple shortcut to allow sharing all sorts of media from iOS with any desktop OS. It allows sending content right from the share sheet - similar to AirDrop between Apple Devices
MIT License
49 stars 3 forks source link

Request parsing fails when using Werkzeug>2.0.3 #39

Open mofe23 opened 1 year ago

mofe23 commented 1 year ago

Hi, let's start with the good news: THX for your code, after initial debugging it did exactly what i was looking for :)

Now the bad ones:

After solving installation problems of wxPython by running pip install attrdict3 before installing orangeshare, I've discovered further problems using Python 3.10 on ArchLinux:

When I tried to add a new device, an alert popped up saying

Error: {"message": "The browser (or proxy) sent a request that this server could not understand."}

After some initial confusion, I discovered the problem was introduced in Werkzeug's version 2.1.0 by a change of Request.get_json() now raising BadRequest Errors if ContentType not explicitly set to application/json.

Several ways to fix orangeshare exist. I've confirmed setting contentType="application/json" and using JSON.stringify for every $.post works. Also, installing Wertkzeug==2.0.3 fixes the issue, but I think explicitly setting location="form" in RequestParser.add_argument is the "most correct" fix, as is keeps your initial intent of sending FormData and as you're rewriting the server side anyway, I'd prefer not to change the JS part --> PR incoming!.

Furthermore, to prevent issues like this one introduced by 3rd party updates, I'd recommend pinning dependencies to versions known to work.

Have a good one, Mo