requests icon indicating copy to clipboard operation
requests copied to clipboard

Fix the proxy_bypass_registry function all returning true in some cases.

Open flysee opened this issue 2 years ago • 2 comments

With the context code,i think we should avoid this situation with empty strings,thx!

flysee avatar Dec 07 '22 11:12 flysee

There's no clear description of a bug, how to reproduce or even tests to show this fixes something. Further you speak of empty strings and are filtering on None which are not the same thing.

sigmavirus24 avatar Dec 07 '22 14:12 sigmavirus24

The value of proxyOverride is controlled by a third-party program on the computer, so it is not controllable. For example, when I use fiddler on my computer, this value is <-loopback>;.(Not all computers) When proxyOverride splits, it's equal to ['<-loopback>', '']. So re.match('', host, re.I) will return true,that bypassing the proxy.

And filter(function, iterable) is equivalent to the generator expression (item for item in iterable if item) if function is None,that is, all elements of iterable that are false are removed. Ref:https://docs.python.org/3/library/functions.html#filter

I think should be avoided for code robustness.

flysee avatar Dec 08 '22 08:12 flysee

The value of proxyOverride is controlled by a third-party program on the computer, so it is not controllable. For example, when I use fiddler on my computer, this value is <-loopback>;.(Not all computers) When proxyOverride splits, it's equal to ['<-loopback>', '']. So re.match('', host, re.I) will return true,that bypassing the proxy.

And filter(function, iterable) is equivalent to the generator expression (item for item in iterable if item) if function is None,that is, all elements of iterable that are false are removed. Ref:https://docs.python.org/3/library/functions.html#filter

I think should be avoided for code robustness.

Yes, I also noticed this situation. This wastes a lot of my time discovering this problem. ProxyOverride sometimes ends with a semicolon and is difficult to reproduce. But it has not yet been merged into the main branch.

aaronhua123 avatar Mar 13 '24 16:03 aaronhua123

The value of proxyOverride is controlled by a third-party program on the computer, so it is not controllable. For example, when I use fiddler on my computer, this value is <-loopback>;.(Not all computers) When proxyOverride splits, it's equal to ['<-loopback>', '']. So re.match('', host, re.I) will return true,that bypassing the proxy. And filter(function, iterable) is equivalent to the generator expression (item for item in iterable if item) if function is None,that is, all elements of iterable that are false are removed. Ref:https://docs.python.org/3/library/functions.html#filter I think should be avoided for code robustness.

Yes, I also noticed this situation. This wastes a lot of my time discovering this problem. ProxyOverride sometimes ends with a semicolon and is difficult to reproduce. But it has not yet been merged into the main branch.

I'm glad someone else is having the same problem as me, but I also hope that no one will waste time on this issue in the future, haha.

flysee avatar Mar 15 '24 02:03 flysee

@flysee can you add tests for this change so it does not regress?

sigmavirus24 avatar Mar 17 '24 13:03 sigmavirus24

@flysee can you add tests for this change so it does not regress?

Of course, test cases have been added.

flysee avatar Mar 18 '24 11:03 flysee