-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
bugIncorrect behavior in the current implementation that needs fixingIncorrect behavior in the current implementation that needs fixingwasi:implIssues pertaining to WASI implementation in WasmtimeIssues pertaining to WASI implementation in Wasmtime
Description
Consider this test for what the HTTP implementation does with invalid field names. First it tries a field name with a space in it, then it tries "
. Both of these are invalid, but the first shows an error on fields.delete
whereas the second does not:
extern crate wit_bindgen;
wit_bindgen::generate!({
inline: r"
package test:test;
world test {
include wasi:http/[email protected];
}
",
additional_derives: [PartialEq, Eq, Hash, Clone],
features:["clocks-timezone"],
generate_all
});
use wasi::http::types::Fields;
use wasi::http::types::HeaderError;
fn test_invalid_field_name(field: &str) {
println!("testing field: {}", field);
let fields = Fields::new();
assert!(!fields.has(field));
assert_eq!(fields.delete(field),
Err(HeaderError::InvalidSyntax));
}
fn test_invalid_field_names() {
test_invalid_field_name("field with space");
test_invalid_field_name("\"");
}
fn main() {
test_invalid_field_names();
}
Run it:
$ cargo +nightly build --target=wasm32-wasip2 --release && wasmtime -Wcomponent-model-async -Sp3,http target/wasm32-wasip2/release/field-invalid.wasm
Compiling test-wasm32-wasip3 v0.1.0 (/home/wingo/src/wasip3/wasi-testsuite/tests/rust/wasm32-wasip3)
Finished `release` profile [optimized] target(s) in 0.35s
testing field: field with space
testing field: "
thread 'main' (1) panicked at src/bin/field-invalid.rs:23:5:
assertion `left == right` failed
left: Ok(())
right: Err(HeaderError::InvalidSyntax)
Metadata
Metadata
Assignees
Labels
bugIncorrect behavior in the current implementation that needs fixingIncorrect behavior in the current implementation that needs fixingwasi:implIssues pertaining to WASI implementation in WasmtimeIssues pertaining to WASI implementation in Wasmtime