costastf / locationsharinglib

A library to retrieve coordinates from an google account that has been shared locations of other accounts.
MIT License
170 stars 29 forks source link

InvalidCookieFile for cookies with whitespace in value #107

Closed Abolfazl closed 1 year ago

Abolfazl commented 1 year ago

I have been having some trouble with loading my cookie files for some time. After a lot of digging I found it's because Google is returning some extra fields.

Here is the line in my cookies.txt file that is causing InvalidCookieFile exception to be raised:

cloud.google.com    FALSE   /   FALSE   0   FACET_EXPERIMENT_IDS_DEVSITE    [39300012, 39300021, 39300118, 39300191, 39300195, 39300251, 39300318, 39300320, 39300326, 39300333, 39300345, 39300354, 39300363, 39300374, 39300411, 39300421, 39300434, 39300472]

The problem is that calling *line.strip().split() splits on every whitespace

I fixed this problem by changing

 cookies = [Cookie(*line.strip().split()) for line in cookies_file.read().splitlines() if not line.strip().startswith('#') and line]

to

cookies = [Cookie(*line.strip().split()) for line in cookies_file.read().splitlines() if not line.strip().startswith('#') and line and len(line.strip().split()) == 7]
costastf commented 1 year ago

Hi @Abolfazl , do you mind giving https://github.com/costastf/locationsharinglib/tree/feature-more-robust-cookie-parsing a test run? It should be handling your cookie issue. (Those cookies should not be in there in the first place, but the tool should indeed be more forgiving in parsing them, thanks for reporting!)

costastf commented 1 year ago

Hi @Abolfazl v5.0.1 should be handling this properly. Thanks for reporting!