Code Monkey home page Code Monkey logo

Comments (4)

wavenator avatar wavenator commented on June 22, 2024

BTW, after fixing this bug I found another bug. Fixing this bug made check_ws_vs_http_matching failing.
The test looks like this:

let network_filter = NetworkFilter::parse("|ws://$domain=4shared.com", true).unwrap();
assert!(network_filter.matches(&request::Request::from_urls("ws://example.com", "4shared.com", "websocket").unwrap()));

Changing "4shard.com" to http://4shared.com fixed the problem. Now there is a question here. Does a WebSocket send an http referrer in a URL format or it is just a domain. If it will always send a URL, we should fix the tests to a URL rather than a domain. If there is a possibility they send domains, there is a problem with parsing the source_url from the domain (which is reasonable), and we need to fix that. Either way, I think we should add negative tests there to show that there is a bug right now.
As a piece of evidence, the following code passes.

let network_filter = NetworkFilter::parse("|ws://$domain=4shared.com", true).unwrap();
assert!(network_filter.matches(&request::Request::from_urls("ws://example.com", "3shared.com", "websocket").unwrap()));

from adblock-rust.

wavenator avatar wavenator commented on June 22, 2024

It raises another question. Now that I think about it, why do we even compare it against the source_url and not against the URL of the request? When the request_url is an absolute URL, the comparison should be against the URL and not against the source URL.

from adblock-rust.

antonok-edm avatar antonok-edm commented on June 22, 2024

Good catches, That check_ws_vs_http_matching test is definitely wrong, those need to be full URLs.

If I understand your last question correctly, we need source_url because there are some rules which are applied differently depending on the page the request is made from. For example, ||a.com$domain=b.com will only block requests to a.com made from b.com. It's also taken into account for $first-party and $third-party options.

Since check_network_urls really depends on source_url to make a correct decision, there should realistically be an error returned if it's not supplied, or doesn't parse correctly.

I'm not actually that familiar with WebSocket referrers, but it shouldn't matter - source_url should just be the top-level URL of the page from which the WebSocket was initiated.

from adblock-rust.

wavenator avatar wavenator commented on June 22, 2024

If you need any help with fixing the bug, I'd be happy to help.

from adblock-rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.