From 442636c131ccbd4f0447e1bb02d0222f8edcc840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bennet=20Ble=C3=9Fmann?= Date: Fri, 4 Oct 2024 19:09:35 +0200 Subject: [PATCH 1/3] add test for load_html --- tests-pl/issue2588.pl | 5 +++++ tests/scryer/issues.rs | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 tests-pl/issue2588.pl diff --git a/tests-pl/issue2588.pl b/tests-pl/issue2588.pl new file mode 100644 index 00000000..4e87a39a --- /dev/null +++ b/tests-pl/issue2588.pl @@ -0,0 +1,5 @@ +:- use_module(library(sgml)). + +test :- load_html("Hello!", Es, []), write(Es). + +:- initialization(test). \ No newline at end of file diff --git a/tests/scryer/issues.rs b/tests/scryer/issues.rs index 821bbbf3..24600d5d 100644 --- a/tests/scryer/issues.rs +++ b/tests/scryer/issues.rs @@ -170,3 +170,8 @@ fn call_0() { " error(existence_error(procedure,call/0),call/0).\n", ); } + +#[test] +fn issue2588_load_html() { + load_module_test("tests-pl/issue2588.pl", "[element(html,[],[element(head,[],[element(title,[],[[H,e,l,l,o,!]])]),element(body,[],[])])]"); +} From e9f03c89a68c32197c4f712f721b66feef474ee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bennet=20Ble=C3=9Fmann?= Date: Fri, 4 Oct 2024 19:25:34 +0200 Subject: [PATCH 2/3] fix issue #2588 --- src/machine/system_calls.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index a092633e..6dad3152 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -7758,7 +7758,7 @@ impl Machine { .value_to_str_like(self.machine_st.registers[1]) { let document = scraper::Html::parse_document(&string.as_str()); - let result = self.html_node_to_term(document.tree.root()); + let result = self.html_node_to_term(document.tree.root().first_child().unwrap()); unify!(self.machine_st, self.machine_st.registers[2], result); } else { From 6dd0ec0b98c627f1497e73b053edf9b26527b4df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bennet=20Ble=C3=9Fmann?= Date: Fri, 4 Oct 2024 20:25:02 +0200 Subject: [PATCH 3/3] fix miri --- tests/scryer/issues.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/scryer/issues.rs b/tests/scryer/issues.rs index f5b58a0f..de318708 100644 --- a/tests/scryer/issues.rs +++ b/tests/scryer/issues.rs @@ -13,6 +13,7 @@ fn call_0() { } #[test] +#[cfg_attr(miri, ignore = "unsupported operation when isolation is enabled")] fn issue2588_load_html() { load_module_test("tests-pl/issue2588.pl", "[element(html,[],[element(head,[],[element(title,[],[[H,e,l,l,o,!]])]),element(body,[],[])])]"); }