Skip to content

Panic parsing Google 4th of July homepage #490

Description

@MorganBennetDev

Using blitz 0.2.1, blitz_html panics when attempting to parse the Google homepage with the message:

thread 'main' (179535) panicked at ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/blitz-dom-0.2.4/src/document.rs:550:13:
to be able to resolve /web/20260703180215cs_/https://www.google.com/xjs/_/ss/k=xjs.hd.jILEt-ueYLk.L.B1.O/am=AAAEQAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAQAAgEABAIAMAAAAAAAIAACgBhEAgAAAAAAAAIQHAAAMAAAAAAAAAIAAAAAAAIAAAIAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAEAAigAAIAABQAAAAAAgAAAAAAAAAAAAAICAAAAAAAAAAAAgAAAAAAAAAAYAMEAIAAAAAAgDAAAAAAAAAAAAAAAAAAAAAAAiARAAAAEAAAAAAABAAAAAAABAIQQBAABCiAAAAAAAACABQAAAAAdQAAEBAAAAAAAAAACAEEgBBAAAAAgAAAABAABAAEAAQEARtAAACQqEAAAogMAAAAIAAAAAIAAAAAAAAAAAAAAQAQAAAAAAACwAABDQCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAE/d=1/ed=1/rs=ACT90oHwnyY8rZ_swysHVUPbUAsB_rKaAw/m=cdos,hsm,jsa,mb4ZUb,cEt90b,SNUn3,qddgKe,sTsDMc,dtl0hd,eHDfl,YV5bee,d,csi?cb=121509378 with the base_url: Url { scheme: "data", cannot_be_a_base: true, username: "", password: None, host: None, port: None, path: "text/css;charset=utf-8;base64,", query: None, fragment: None }

It also produces the same panic on the archive.org snapshot. I've included the code I used to produce this panic below.

Details
use blitz::dom::net::Resource;
use blitz::dom::DocumentConfig;
use blitz::html::HtmlDocument;
use blitz::shell::{create_default_event_loop, BlitzShellEvent, BlitzShellNetCallback};
use blitz::traits::net::Request;
use std::sync::Arc;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    tracing_subscriber::fmt::init();

    let event_loop = create_default_event_loop::<BlitzShellEvent>();
    let net_provider = create_net_provider(&event_loop);
    let (_, bytes) = net_provider
        .fetch_async(Request::get(url::Url::parse("https://www.google.com")?))
        .await
        .unwrap();
    let html = std::str::from_utf8(&bytes)?;

    let doc = HtmlDocument::from_html(html, DocumentConfig::default());

    Ok(())
}

type EnabledNetProvider = blitz::net::Provider<Resource>;

fn create_net_provider(
    event_loop: &blitz::shell::EventLoop<BlitzShellEvent>,
) -> Arc<EnabledNetProvider> {
    let proxy = event_loop.create_proxy();
    let callback = BlitzShellNetCallback::shared(proxy);
    Arc::new(blitz::net::Provider::new(callback))
}

This seems to be due to the parser attempting to use a data: URL as a base and failing.

Side note: Is there a setting I've missed that disables blitz attempting to resolve URLs during parsing? This seems like something that should either be configurable or not part of the parser.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions