Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/webxdc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,11 @@ fn parse_webxdc_manifest(bytes: &[u8]) -> Result<WebxdcManifest> {
}

async fn get_blob(archive: &mut SeekZipFileReader<BufReader<File>>, name: &str) -> Result<Vec<u8>> {
let (i, _) =
let (i, zip_entry) =
find_zip_entry(archive.file(), name).ok_or_else(|| anyhow!("no entry found for {name}"))?;
if zip_entry.uncompressed_size() > 100_000_000 {
bail!("Webxdc file {name} is too large");
}
let mut reader = archive.reader_with_entry(i).await?;
let mut buf = Vec::new();
reader.read_to_end_checked(&mut buf).await?;
Expand Down
16 changes: 16 additions & 0 deletions src/webxdc/webxdc_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,22 @@ async fn test_get_webxdc_blob_with_subdirs() -> Result<()> {
Ok(())
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_1g_index_blob() -> Result<()> {
let t = TestContext::new_alice().await;
let chat_id = create_group(&t, "foo").await?;
let mut instance = create_webxdc_instance(
&t,
"1gb-index-file.xdc",
include_bytes!("../../test-data/webxdc/1g-index-file.xdc"),
)?;
chat_id.set_draft(&t, Some(&mut instance)).await?;

assert!(instance.get_webxdc_blob(&t, "index.html").await.is_err());

Ok(())
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_parse_webxdc_manifest() -> Result<()> {
let result = parse_webxdc_manifest(r#"key = syntax error"#.as_bytes());
Expand Down
Binary file added test-data/webxdc/1g-index-file.xdc
Binary file not shown.
Loading