woheller69 / browser

A privacy oriented web browser with Greasemonkey style script support and Cookie Banner Blocker
GNU General Public License v3.0
160 stars 18 forks source link

crash in BannerBlock -- truncated file #48

Closed StevanWhite closed 2 weeks ago

StevanWhite commented 2 weeks ago

Managed to build and run your app in VS 2023.3.1.

It crashes on start-up. I debugged it, and the cause is pretty clear.

It reads the first 5k from https://raw.githubusercontent.com/mozilla/cookie-banner-rules-list/main/cookie-banner-rules-list.json but that file is more than 5k, so it gets truncated.

In loadHosts(), this causes a JSONException, which throws a RuntimeException.

First, rather than throwing the RuntimeException, I suggest that instead you Log the error. The app continues to run without this facility.

Second, a fix to the problem would involve correcting the code that downloads the file (NOT just increasing the buffer size.)

Cheers!@

woheller69 commented 2 weeks ago

I think this is rather an issue with your environment. This download mechanism has been in place without any issues for many years. It is used in the same way for downloading StevenBlack hosts.

StevanWhite commented 2 weeks ago

It may be that something in the emulator environment cuts the transmission off, I can't say. But this kind of problem could happen for any number of reasons.

The code response to it, of simply giving up and crashing, is a bad idea.

My suggestion, again, is to at least log the exception and continue. For production code, it would be best to inform the user that the functionality will be unavailable, and explain why.

Cheers!

woheller69 commented 2 weeks ago

I made some adjustments: https://github.com/woheller69/browser/commit/13b8f4178a3fdf4881f34182eec5b80e5e8248d8