leptris 1.9.364.2 → 1.9.365.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25ec026b62db4292174aa0b8a21c05b190e1ffe093338fe20dbcd8aae8a36f88
4
- data.tar.gz: f55e338728aa84d4db652a556d4ab965e456caefadb5de21da67f8163d3de142
3
+ metadata.gz: 973845563957861b68366fd3c90f3a8d3f1a5ba5921e09f2a2dc268542faa8b6
4
+ data.tar.gz: 71814d603d2c40586dc2e3c3aa9d36750e67a8cdb54864257a9f56cfa076a6c8
5
5
  SHA512:
6
- metadata.gz: 32a4123617821dc14b225c06d71ddf87239f09f432f76f201e65fc70b8aa511f1816204b5815dee2e8b901d308993b21e197403b6315f43e71a5cc404adeaa69
7
- data.tar.gz: 79d51794b1ef9a913d3335241de229be6d8f8698c111af5b725f95b1a8ce8e9f93edc4f5fa3102ff3d719797ea5a8fb7ef4bd6878d55fd578bdc1fc5f326d0c0
6
+ metadata.gz: f298b9d5e3ac0ffd299ee2323b4efcadddd2c7c7f09be765009c3764d99bbfeb88e3720a92888fbfda3195dfa5bededeca05e38c1790c7c2071fd87807718ed8
7
+ data.tar.gz: ea9086febdac6a55cb745ce9c240ed7ea2db9ac26843b6b1bfcca43c873a9fbcce1f522dff609ef83a8c62e9af98120d6e9dad18649ba0ec3ea77556c215d0cd
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
8
8
  # Pin for `rake compile` and the platform-gem builds. Keep in lockstep
9
9
  # with .github/workflows/build.yml (which calls `rake compile`) and the
10
10
  # CHANGELOG when libleptris releases.
11
- LIBLEPTRIS_VERSION = "1.9.364"
11
+ LIBLEPTRIS_VERSION = "1.9.365"
12
12
  # Vendored alongside libleptris for fn:normalize-unicode (TODO
13
13
  # .restructure/20): built per platform with a RELOCATABLE @rpath
14
14
  # install name, loaded by ffi.rb before libleptris so the
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.364.2"
4
+ VERSION = "1.9.365.1"
5
5
  end
data/vendor-src/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Sources vendored in this gem (recompile rights; the ruby
2
2
  variant builds them at install via extconf.rb):
3
3
 
4
- - libleptris v1.9.364
4
+ - libleptris v1.9.365
5
5
  - utf8proc v2.11.0
6
6
 
7
7
  Rebuild by hand:
@@ -1,5 +1,23 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.9.365] - 2026-10-16
4
+
5
+ ### Fixed
6
+
7
+ - **html4: skip the XML-declaration construct in HTML input (#1748, PR #1754).**
8
+ The html4 lane parsed `<?xml ...?>` as a PI node (target `xml`) whose data
9
+ carried the terminator `?`, so serialization emitted
10
+ `<?xml version="1.0" encoding="UTF-8"??>` — and with the serializer's
11
+ `xml_declaration` riding along (the default `to_xml`), the output carried
12
+ two declarations, which canon's XHTML pretty-printer degenerated to
13
+ declaration-only output downstream. libxml2's HTML parser skips the
14
+ XML-declaration construct entirely; the html4 lane now does the same (the
15
+ WHATWG lane keeps its specified bogus-comment shape). Red-first gtest pins
16
+ the contract: `xml_declaration=0` emits no declaration, `1` emits exactly
17
+ the serializer's own — never the input's remnant, never `??`. Engine suite
18
+ 2047/2047; canon's battery 9/9.
19
+
20
+
3
21
  ## [1.9.364] - 2026-10-16
4
22
 
5
23
  ### Added
@@ -3,7 +3,7 @@
3
3
  cmake_minimum_required(VERSION 3.20)
4
4
 
5
5
  project(leptris
6
- VERSION 1.9.364
6
+ VERSION 1.9.365
7
7
  DESCRIPTION "Fast XML parser and XPath evaluator in pure C"
8
8
  LANGUAGES C CXX
9
9
  )
@@ -6685,6 +6685,19 @@ static LeptrisDocument html_parse_shared(
6685
6685
  size_t dlen = (size_t)(de > ds ? de - ds : 0);
6686
6686
  char* tgt = (char*)leptris_pool_alloc(b.pool, tlen + 1);
6687
6687
  char* dat = (char*)leptris_pool_alloc(b.pool, dlen + 1);
6688
+ /* libxml2 HTML parity (#1748): the XML-declaration
6689
+ * construct ('<?xml ...?>') is an XML-ism — the HTML
6690
+ * lane skips it entirely. Retaining it as a PI made the
6691
+ * data carry the terminator '?' (serialized
6692
+ * '<?xml ...??>'), and the declaration metadata + PI
6693
+ * doubled when the serializer's xml_declaration rode
6694
+ * along. */
6695
+ if (tlen == 3 && (ts[0] | 0x20) == 'x' &&
6696
+ (ts[1] | 0x20) == 'm' && (ts[2] | 0x20) == 'l') {
6697
+ p = (de < end) ? de + 1 : end;
6698
+ text = p;
6699
+ continue;
6700
+ }
6688
6701
  if (tgt && dat) {
6689
6702
  memcpy(tgt, ts, tlen);
6690
6703
  tgt[tlen] = 0;
@@ -188,3 +188,43 @@ TEST(HtmlBuilder, RawTextElementNotEscaped) {
188
188
  EXPECT_EQ(out.find("&lt;"), std::string::npos) << out;
189
189
  leptris_document_free(d);
190
190
  }
191
+
192
+ /* leptris#1748: the XML-declaration construct ('<?xml ...?>') in
193
+ * HTML input is an XML-ism — libxml2's HTML parser skips it, and
194
+ * retaining it as a PI (data carrying the terminator '?') made
195
+ * serialization emit '<?xml ...??>' and double the declaration when
196
+ * the serializer's own xml_declaration rode along. */
197
+ TEST(HtmlBuilder, Html4DropsXmlDeclarationProlog) {
198
+ const char* html =
199
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
200
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\">"
201
+ "<head><title>t</title></head><body><p>x</p></body></html>";
202
+ LeptrisStatus st = LEPTRIS_OK;
203
+ LeptrisDocument d =
204
+ leptris_parse_html4_string(html, strlen(html), &st);
205
+ ASSERT_EQ(st, LEPTRIS_OK);
206
+ ASSERT_NE(d, nullptr);
207
+ for (int decl = 0; decl < 2; decl++) {
208
+ LeptrisSerializeOptions opts;
209
+ memset(&opts, 0, sizeof(opts));
210
+ opts.xml_declaration = decl;
211
+ opts.encoding = "UTF-8";
212
+ char* s = leptris_document_serialize(d, &opts);
213
+ ASSERT_NE(s, nullptr);
214
+ std::string out(s);
215
+ leptris_free_string(s);
216
+ EXPECT_EQ(out.find("??"), std::string::npos)
217
+ << "decl=" << decl << " got: " << out.substr(0, 90);
218
+ /* decl=0: the prolog never leaks. decl=1: exactly the
219
+ * serializer's own declaration — never two, never the
220
+ * input's remnant. */
221
+ size_t decls = 0;
222
+ for (size_t at = out.find("<?xml"); at != std::string::npos;
223
+ at = out.find("<?xml", at + 1))
224
+ decls++;
225
+ EXPECT_EQ(decls, (size_t)decl)
226
+ << "decl=" << decl << " got: " << out.substr(0, 90);
227
+ EXPECT_NE(out.find("<html"), std::string::npos) << out;
228
+ }
229
+ leptris_document_free(d);
230
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
3
3
  "name": "leptris",
4
- "version": "1.9.364",
4
+ "version": "1.9.365",
5
5
  "description": "High-performance XML parser and XPath 1.0 engine in C (libleptris)",
6
6
  "homepage": "https://github.com/leptris/leptris",
7
7
  "license": "MIT",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.364.2
4
+ version: 1.9.365.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.