This repository has been archived by the owner on Sep 7, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1749 from unixfox/patch-1
[fix] Force Google old UI with a new user agent
- Loading branch information
2a527b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a doubt, that this patch does what you think. The result of the string concatenation is:
You see the missing space after the parentheses, in front of 'AppleWebK..'? Is this really a valid (or an expectable) value for a User-Agent field?
2a527b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The concatenation is incorrect but the patch still works thanks to the parenthesis just before the
AppleWebKit
.You can see it in action here: https://developers.whatismybrowser.com/useragents/parse/#parse-useragent
Try to remove the parenthesis and you will see that
whatismybrowser.com
will interpret it as a different user agent.Anyway in the end it's my fault, I don't often deal with python so that's why I made this mistake when I tried to write the patch as pep8 compliant.
2a527b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for sharing the link. One note, we do not know how the peer is interpreting .. for developers.whatismybrowser.com it seems to be ok to miss the space, but you already said ..
Ah, OK .. no problem. I recommend an editor with a good python support. I do prefer emacs, other prefer pycharm. Such editors can help with auto-indent and more:
Another hint, did you know The Hitchhiker’s Guide to Python!, a really good starting point .. and reference .. for me and other .. all the time :)
If I can help you any more in python, don't hesitate to contact me directly markus.heiser@darmarit.de
2a527b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do think that Google is parsing the User Agent the same way as whatismybrowser because I get the old UI with this user agent:
But not with this one:
I'm using Visual Studio Code which is a good editor with the
Python
extension. The extension does have an auto-indent but not for an auto-concatenation.The mistake that I made is mostly due to the fact that I'm not used to do the concatenation style that pep8 requires.
2a527b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for verifying both headers (teh one with space and the one without the needed space) .. This is the reason why I said first:
I guess your conclusion false: for whatismybrowser it does not matter if the space is missed, for google it matters .. this is what your test with both headers shows.
At the end google thinks it can't detect the browser so it response with the old UI ... that is what I guess and why I started this discussion.
2a527b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it doesn't for Google, read again the user agent. The first one is the same as the patch.
And the second one is to check that indeed the parenthesis is important for having a good user agent.
Google is interpreting the same way as whatismybrowser
2a527b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aargh, my fail ..haven't realized, that you talking about "missing parenthesis", while I am talking about the "missing space" .. in front of this closing parenthesis ...
Thanks for clarifying!