makiri 0.16.0-aarch64-linux → 0.17.0.rc1-aarch64-linux
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 +4 -4
- data/CHANGELOG.md +89 -0
- data/NOKOGIRI_DIFFERENCES.md +52 -48
- data/NOTICE +7 -0
- data/README.md +9 -6
- data/lib/makiri/3.2/makiri.so +0 -0
- data/lib/makiri/3.3/makiri.so +0 -0
- data/lib/makiri/3.4/makiri.so +0 -0
- data/lib/makiri/4.0/makiri.so +0 -0
- data/lib/makiri/version.rb +1 -1
- data/lib/makiri/xml/node_methods.rb +14 -30
- data/vendor/lexbor/LICENSE +223 -0
- data/vendor/lexbor/NOTICE +16 -0
- metadata +8 -23
- data/.github/workflows/ci.yml +0 -204
- data/.github/workflows/conformance.yml +0 -135
- data/.github/workflows/css-match.yml +0 -217
- data/.github/workflows/libfuzzer.yml +0 -116
- data/.github/workflows/release.yml +0 -273
- data/.github/workflows/security.yml +0 -305
- data/.github/workflows/valgrind.yml +0 -187
- data/.github/workflows/verify.yml +0 -71
- data/.gitmodules +0 -3
- data/Rakefile +0 -946
- data/script/api_manifest.rb +0 -173
- data/script/build_native_gem.rb +0 -53
- data/script/check_alloc_failures.rb +0 -815
- data/script/check_leaks.rb +0 -64
- data/script/check_unsafe_boundaries.rb +0 -782
- data/script/leaks_harness.rb +0 -90
- data/suppressions/ruby.supp +0 -194
- data/tools/pe_exports.rb +0 -124
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8710995de3498cde22ec02966971c541ba7ba3f2c9176be2566c93008bdcd82d
|
|
4
|
+
data.tar.gz: b6fd0ff75de338b8cab9b7c3ec74edd471ba64c17094ebcb50e3432818820172
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 173b0f7471ff9c615421b91ab848326990b8c9706c54cbc2049b216b1d71c15147b950f73a323ddb2e13a0580d7644453a61476cff46952cf4419c25233a2d95
|
|
7
|
+
data.tar.gz: 63d50aab4ee8a15570215b275a566d1dbbc1b11ad22551564cc5e790821711ea57feee4432c1bf28e18a3c1e2aa0251b6a30433df562aae7cfd84e6b580acfb8
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,94 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
## [0.17.0.rc1] - 2026-10-22
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
* `Makiri::Lexbor::CSS.parse_stylesheet` returns the declarations in an
|
|
10
|
+
at-rule's block (`@font-face`, `@page`, ...) as its `:declarations`; they
|
|
11
|
+
were dropped.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
* HTML is parsed by Makiri's own Rust port of Lexbor's tokenizer and tree
|
|
16
|
+
builder, into a DOM of Makiri's own, and the CSS selector and stylesheet
|
|
17
|
+
parsers are ported too. A parsed document takes about 40% less memory.
|
|
18
|
+
* Installing from source needs Rust 1.84 or newer (and libclang), and no
|
|
19
|
+
longer CMake: the gem carries none of Lexbor's sources, only its LICENSE
|
|
20
|
+
and NOTICE.
|
|
21
|
+
* `Makiri::XML`'s `#css`, `#at_css` and `#matches?` run on the same matcher
|
|
22
|
+
as HTML's and answer as a browser's `querySelectorAll` does in an XML
|
|
23
|
+
document, 10-20x faster on compound selectors (`.item`, `ul li.item`).
|
|
24
|
+
This changes some answers:
|
|
25
|
+
* a bare type selector (`p`) matches that name in any namespace;
|
|
26
|
+
* the root element's namespace declarations are no longer picked up: a
|
|
27
|
+
prefix must be given in the ns Hash, whose `"xmlns"` entry is the
|
|
28
|
+
default namespace (on HTML too);
|
|
29
|
+
* a selector run on a node may match through ancestors outside it
|
|
30
|
+
(`node.css("body p")`); only the node's descendants are returned;
|
|
31
|
+
* `[a=v i]`, `:nth-child(... of S)`, and the form-state and link
|
|
32
|
+
pseudo-classes on XHTML elements are supported;
|
|
33
|
+
* `||` and `:current()` raise `Makiri::CSS::SyntaxError`, and an over-long
|
|
34
|
+
chain `Makiri::Error` (it was `Makiri::XPath::LimitExceeded`).
|
|
35
|
+
* HTML `css(selector, ns)` resolves namespace prefixes: `svg|path` is the SVG
|
|
36
|
+
`path`, `|p` an element in no namespace, `[x|href]` the attribute in `x`'s
|
|
37
|
+
namespace. A prefix the Hash does not bind raises
|
|
38
|
+
`Makiri::CSS::SyntaxError`; prefixes used to be ignored.
|
|
39
|
+
* HTML parsing follows the HTML Standard where Lexbor did not. This affects
|
|
40
|
+
malformed or unusual markup only: `<frameset>`, `<form>` and tables inside
|
|
41
|
+
`<template>`, `<![CDA` or `<!` at the end of the input, the adoption
|
|
42
|
+
agency, `<textarea>`, `<input type=HIDDEN>` and `<image>` in a table,
|
|
43
|
+
`<sup>` in SVG or MathML, and a repeated attribute name (the first is
|
|
44
|
+
kept). Fragment parsing (`#inner_html=`, `#outer_html=`, `Node#parse`,
|
|
45
|
+
`context:` given an element) takes the context element's quirks mode,
|
|
46
|
+
namespace and ancestor `<form>` into account, as browsers do.
|
|
47
|
+
* CSS selectors are parsed as Selectors 4 says: `:has()` inside `:has()` and
|
|
48
|
+
an invalid argument to `:has()` make the selector invalid, an empty
|
|
49
|
+
`:is()` / `:where()` is valid and matches nothing, and `#1a` is not an ID
|
|
50
|
+
selector.
|
|
51
|
+
* `parse_stylesheet` reads names and values by one rule for every property: a
|
|
52
|
+
declaration name is lower-cased unless it is a custom property, an at-rule
|
|
53
|
+
name is lower-cased, and a value is the text as written with whitespace
|
|
54
|
+
runs collapsed (`color: RED` stays `RED`; it came back as `red`).
|
|
55
|
+
`:specificity` is counted as Selectors 4 does (`:is()` / `:not()` /
|
|
56
|
+
`:has()` take their most specific argument).
|
|
57
|
+
|
|
58
|
+
### Removed
|
|
59
|
+
|
|
60
|
+
* The 10,000-`<option>` limit on a `<select>`: a select with any number of
|
|
61
|
+
options parses in linear time, as browsers parse it.
|
|
62
|
+
|
|
63
|
+
### Fixed
|
|
64
|
+
|
|
65
|
+
* `parse_stylesheet` keeps a rule such as `a:hover { ... }` inside `@media`
|
|
66
|
+
or `@supports`; it was read as a declaration, which dropped that rule and
|
|
67
|
+
every one after it in the block. A comment between a declaration's name
|
|
68
|
+
and its `:` no longer drops the declarations that follow.
|
|
69
|
+
* A namespaced type selector in the middle of a compound (`.x|a`) raises
|
|
70
|
+
`Makiri::CSS::SyntaxError`, as browsers do.
|
|
71
|
+
* `:any-link` / `:link` match only an HTML `a` or `area`, or an SVG `a`, with
|
|
72
|
+
an `href` (`<link href>` and `<map>` matched). `:read-write` /
|
|
73
|
+
`:read-only` follow the HTML Standard (a checkbox is read-only, an element
|
|
74
|
+
inside `contenteditable` is read-write), and `:empty` ignores processing
|
|
75
|
+
instructions.
|
|
76
|
+
* HTML's `:nth-child` family counts element siblings only:
|
|
77
|
+
`html:first-child` matched nothing after `<!doctype html>`.
|
|
78
|
+
* An attribute keeps the namespace it was made in: `set_attribute_ns` in the
|
|
79
|
+
element's own namespace replaces the attribute it set before instead of
|
|
80
|
+
adding a second, and an attribute removed from its element keeps its
|
|
81
|
+
`namespace_uri`.
|
|
82
|
+
* An attribute name is serialized in the case it was set (`e["viewBox"]` on
|
|
83
|
+
an element in no namespace was written lower-cased).
|
|
84
|
+
* A void element's `#inner_html` is empty even when it has children, and a
|
|
85
|
+
prefixed HTML, SVG or MathML element is written by its local name.
|
|
86
|
+
* `Node#line` of a void element fostered out of a table is its line, not nil.
|
|
87
|
+
* Many namespaces created with `create_element_ns` no longer make lookups
|
|
88
|
+
quadratic.
|
|
89
|
+
* `HTML::Document#import_node` given a document raises "cannot import a
|
|
90
|
+
document; use #dup", as `#clone_node` does.
|
|
91
|
+
|
|
3
92
|
## [0.16.0] - 2026-10-10
|
|
4
93
|
|
|
5
94
|
### Added
|
data/NOKOGIRI_DIFFERENCES.md
CHANGED
|
@@ -149,7 +149,7 @@ what browsers do - rather than libxml2. Detailed, test-backed notes live in
|
|
|
149
149
|
* `<?php ... ?>` in HTML input is a **ProcessingInstruction** node; `#to_html`
|
|
150
150
|
writes it back as `<?php ... ?>`, and `<?` at end of input is ignored.
|
|
151
151
|
* The HTML Standard added processing-instruction tokens and tree-construction
|
|
152
|
-
rules for them
|
|
152
|
+
rules for them, and Makiri's parser follows them. `Nokogiri::HTML5` (gumbo)
|
|
153
153
|
still produces the older bogus comment (`<!--?php ... ?-->`), and
|
|
154
154
|
`Nokogiri::HTML` (libxml2) its own comment.
|
|
155
155
|
|
|
@@ -158,17 +158,14 @@ what browsers do - rather than libxml2. Detailed, test-backed notes live in
|
|
|
158
158
|
Nokogiri's. `inner_html=`, `outer_html=` and `Node#parse` take no keyword.
|
|
159
159
|
`Nokogiri::HTML` (libxml2) instead stops at depth 256 and returns the
|
|
160
160
|
truncated document.
|
|
161
|
-
* More than 10,000 `<option>`s in one `<select>` raise `Makiri::Error`;
|
|
162
|
-
Nokogiri has no such limit.
|
|
163
161
|
|
|
164
162
|
## HTML mutation
|
|
165
163
|
|
|
166
164
|
* There is no `Node#name=` / `#node_name=` (on HTML or XML nodes). Nokogiri
|
|
167
165
|
renames a node in place and keeps its identity; the DOM has no rename, and
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
the old one (see CHANGELOG.md).
|
|
166
|
+
an element's tag decides what it is (a `<template>` owns its contents), so a
|
|
167
|
+
node cannot change its tag. Create an element of the new name, move the
|
|
168
|
+
attributes and children, and `replace` the old one (see CHANGELOG.md).
|
|
172
169
|
* Element and attribute names follow the WHATWG DOM's rules
|
|
173
170
|
* `create_element`, `[]=` and `set_attribute_ns` raise `ArgumentError` for a
|
|
174
171
|
name the DOM refuses - one holding whitespace, `/`, `>` (or `=` for an
|
|
@@ -224,26 +221,19 @@ what browsers do - rather than libxml2. Detailed, test-backed notes live in
|
|
|
224
221
|
* One exception to the DOM: an HTML attribute named `xml:lang` (in no
|
|
225
222
|
namespace) becomes the XML namespace's `xml:lang`, as the XML reader reads
|
|
226
223
|
that name, so XHTML-style HTML still writes as XML.
|
|
227
|
-
* A known gap, in Lexbor's tag table: an HTML document that already holds a
|
|
228
|
-
parsed element named with a colon (`<x:y>`, one local name) and then
|
|
229
|
-
receives, by `import_node` from another document, a prefixed element
|
|
230
|
-
written the same way (`x:y` from XML: prefix `x`, local name `y`) re-points
|
|
231
|
-
the table's entry for that spelling - the parsed element then no longer
|
|
232
|
-
matches CSS `x\:y`. Copies within one document do not touch the table.
|
|
233
224
|
* An XML element with a prefix, imported into HTML, keeps it (`h:div` in
|
|
234
225
|
XHTML has the local name `div`). Two readers then disagree, as they do in
|
|
235
|
-
browsers: CSS's `div` matches it (
|
|
236
|
-
`//div` does not (an HTML element's name test reads its qualified
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
element.
|
|
226
|
+
browsers: CSS's `div` matches it (the matcher compares the local name),
|
|
227
|
+
XPath's `//div` does not (an HTML element's name test reads its qualified
|
|
228
|
+
name). `#to_html` writes the local name (`<div>`), as the HTML standard
|
|
229
|
+
does.
|
|
240
230
|
|
|
241
231
|
## CSS
|
|
242
232
|
|
|
243
233
|
* Most jQuery/Nokogiri CSS extensions are not supported (`:gt`, `:lt`, `:eq`, `:first`, ...)
|
|
244
|
-
* Makiri
|
|
245
|
-
|
|
246
|
-
|
|
234
|
+
* Makiri's selector engine is standards-based. Use XPath
|
|
235
|
+
(`xpath("//p[contains(., 'x')]")`) or Enumerable (`css('li')[1]`) for the
|
|
236
|
+
rest.
|
|
247
237
|
Standard Level-4 selectors (`:is` / `:where` / `:has`) are supported; some of which Nokogiri rejects.
|
|
248
238
|
* There is no text-containment pseudo-class. Nokogiri's `:contains()` is
|
|
249
239
|
not supported, and neither is Lexbor's `:lexbor-contains()`: it raises
|
|
@@ -255,33 +245,45 @@ what browsers do - rather than libxml2. Detailed, test-backed notes live in
|
|
|
255
245
|
selector) is supported and correct on both HTML and XML - the "type" is the
|
|
256
246
|
element's own expanded name.
|
|
257
247
|
* Nokogiri (XML and HTML5) mistranslates these to first-/only-child
|
|
258
|
-
(`//*[position()=1]` / `//*[last()=1]`), so it under-matches; Makiri
|
|
259
|
-
|
|
260
|
-
*
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
*
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
248
|
+
(`//*[position()=1]` / `//*[last()=1]`), so it under-matches; Makiri does
|
|
249
|
+
not.
|
|
250
|
+
* CSS resolves a namespace prefix against the `{prefix => uri}` Hash
|
|
251
|
+
(`css(selector, ns)`), on HTML and XML alike: `svg|path` is the SVG `path`
|
|
252
|
+
once `svg` is bound, `|path` an element in no namespace, and a prefix the
|
|
253
|
+
Hash does not bind raises `Makiri::CSS::SyntaxError`. `[x|href]` finds the
|
|
254
|
+
XLink `href` once `x` is bound to XLink. The Hash's `"xmlns"` entry is the
|
|
255
|
+
default namespace, as CSS `@namespace` without a prefix sets one: a type or
|
|
256
|
+
universal selector without a prefix is then in it.
|
|
257
|
+
* Without a default, a bare type selector matches its name in any namespace
|
|
258
|
+
(`path` finds the SVG element, `entry` an Atom entry), as a browser's
|
|
259
|
+
`querySelectorAll` does. `Nokogiri::XML` binds a bare name to the root's
|
|
260
|
+
default namespace when no Hash is given, and to no namespace once one is;
|
|
261
|
+
pass `"xmlns" => uri` (or `"xmlns" => ""`) for that reading.
|
|
262
|
+
* `Makiri::XML` does not collect the document's own declarations: a prefix
|
|
263
|
+
is declared by the Hash or not at all. `Nokogiri::XML` collects the
|
|
264
|
+
root's.
|
|
265
|
+
* A bare `*` under a default namespace is in it, as CSS has it;
|
|
266
|
+
`Nokogiri::XML` matches any element.
|
|
267
|
+
* Up to 0.16 HTML accepted the Hash and ignored every prefix, and
|
|
268
|
+
`Makiri::XML` collected the root's declarations as Nokogiri does.
|
|
273
269
|
* A selector under a node matches the way `Element#querySelectorAll` does in a
|
|
274
|
-
browser, not scoped to that node, on HTML
|
|
275
|
-
`p` inside `#c` when `#c` is itself a
|
|
276
|
-
|
|
277
|
-
`Nokogiri::HTML5` and `Nokogiri::XML` scope
|
|
278
|
-
cannot be the `div`), and so
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
* The attribute case modifiers (`[a="x" i]`, `[a="x" s]`)
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
270
|
+
browser, not scoped to that node, on HTML and XML alike:
|
|
271
|
+
`at_css("#c").css("div p")` finds a `p` inside `#c` when `#c` is itself a
|
|
272
|
+
`div`, since the selector is matched against the whole tree and only the
|
|
273
|
+
results are kept to descendants. `Nokogiri::HTML5` and `Nokogiri::XML` scope
|
|
274
|
+
the selector to the node (`#c` cannot be the `div`), and so did
|
|
275
|
+
`Makiri::XML` up to 0.16. There is no `:scope`; for a scoped match, use XPath
|
|
276
|
+
from the node (`xpath(".//div//p")`).
|
|
277
|
+
* The attribute case modifiers (`[a="x" i]`, `[a="x" s]`) are supported on
|
|
278
|
+
both representations. Nokogiri refuses both on either.
|
|
279
|
+
* The form-state and link pseudo-classes (`:checked`, `:disabled`,
|
|
280
|
+
`:enabled`, `:required`, `:optional`, `:placeholder-shown`, `:link`, ...)
|
|
281
|
+
answer on `Makiri::XML` too, for XHTML elements, as browsers do in an XML
|
|
282
|
+
document; on any other element they match nothing. `Nokogiri::XML` refuses
|
|
283
|
+
them.
|
|
284
|
+
* A selector `Makiri` cannot run (the column combinator `||`, `:current()`)
|
|
285
|
+
raises `Makiri::CSS::SyntaxError`, as a browser's `querySelectorAll` throws a
|
|
286
|
+
SyntaxError, on both representations.
|
|
285
287
|
* `#matches?` answers for a DETACHED node (`document.create_element("p")
|
|
286
288
|
.matches?("p")` is true, on both representations). Nokogiri raises
|
|
287
289
|
`NoMethodError` there - it implements `#matches?` as a search from
|
|
@@ -294,7 +296,9 @@ what browsers do - rather than libxml2. Detailed, test-backed notes live in
|
|
|
294
296
|
therefore matches no type selector.
|
|
295
297
|
* `Nokogiri::HTML5` is case-sensitive on HTML elements too, so `LI` does not
|
|
296
298
|
match `<li>` there. `Makiri::XML`'s `#css` is case-sensitive, as XML names
|
|
297
|
-
are
|
|
299
|
+
are - an XHTML element's included, as in a browser's XML document - and so
|
|
300
|
+
are its attribute values, the HTML Standard's case-insensitive list of
|
|
301
|
+
attributes applying only to an HTML document.
|
|
298
302
|
|
|
299
303
|
## Serialization
|
|
300
304
|
|
data/NOTICE
CHANGED
|
@@ -8,6 +8,13 @@ This product includes software developed by:
|
|
|
8
8
|
Licensed under the Apache License, Version 2.0
|
|
9
9
|
https://lexbor.com / https://github.com/lexbor/lexbor
|
|
10
10
|
|
|
11
|
+
The HTML tokenizer and tree builder under ext/makiri/rust/src/html/ and the
|
|
12
|
+
CSS syntax, selector and stylesheet parser under
|
|
13
|
+
ext/makiri/rust/src/selectors/ are Rust ports of Lexbor's, as are the HTML
|
|
14
|
+
CSS matcher under ext/makiri/rust/src/css_match/ and the tag and
|
|
15
|
+
attribute tables generated from Lexbor's. The extension links no Lexbor
|
|
16
|
+
code; Lexbor's LICENSE and NOTICE are kept under vendor/lexbor/ in the gem.
|
|
17
|
+
|
|
11
18
|
The XPath 1.0 engine under ext/makiri/rust/src/xpath/ is an original
|
|
12
19
|
implementation written for this project. No code is derived from libxml2 or
|
|
13
20
|
libxslt.
|
data/README.md
CHANGED
|
@@ -28,8 +28,7 @@ XPath 1.0 evaluation in its own native engine, with no libxml2 dependency.
|
|
|
28
28
|
differential, and property-based testing vs Nokogiri (see below).
|
|
29
29
|
* Bounded, fail-closed execution
|
|
30
30
|
* XPath evaluation is bounded by per-evaluation limits on work, memory, and recursion.
|
|
31
|
-
* HTML parsing bounds the tree depth (`max_tree_depth:`, default 400)
|
|
32
|
-
`<option>`s per `<select>` (10,000).
|
|
31
|
+
* HTML parsing bounds the tree depth (`max_tree_depth:`, default 400).
|
|
33
32
|
* Ownership and borrowing are kept explicit across layers, with owned/borrowed
|
|
34
33
|
string types and verified text at engine boundaries.
|
|
35
34
|
* Programmatic invalid input, limit violations, allocation failures, and unsupported constructs
|
|
@@ -109,9 +108,10 @@ el = doc.at_xpath("//a:entry", ns)
|
|
|
109
108
|
el.local_name # => "entry"
|
|
110
109
|
el.namespace_uri # => "http://www.w3.org/2005/Atom"
|
|
111
110
|
|
|
112
|
-
# CSS selectors work too
|
|
113
|
-
#
|
|
111
|
+
# CSS selectors work too, as in a browser: a bare type selector matches its
|
|
112
|
+
# name in any namespace, so this just works.
|
|
114
113
|
doc.css("entry").length # => 2
|
|
114
|
+
doc.css("a|entry", ns).length # => 2 (a prefix the Hash binds)
|
|
115
115
|
doc.css("feed > entry").map { |e| e.at_css("title").text } # => ["Hello", "World"]
|
|
116
116
|
|
|
117
117
|
# Serialize back to XML
|
|
@@ -256,10 +256,13 @@ See also [`spec/conformance/README.md`](spec/conformance/README.md).
|
|
|
256
256
|
## Requirements
|
|
257
257
|
|
|
258
258
|
* CRuby 3.2 or newer.
|
|
259
|
-
*
|
|
259
|
+
* Rust 1.84 or newer with `cargo` - the extension is a Rust crate. (Binary
|
|
260
|
+
gems are published for the common platforms, which need no toolchain.)
|
|
260
261
|
* libclang (clang's development library): rb-sys runs bindgen at build time and
|
|
261
262
|
reads Ruby's headers through it.
|
|
262
|
-
|
|
263
|
+
|
|
264
|
+
Development also needs CMake and a C toolchain, to build the vendored Lexbor
|
|
265
|
+
that the Rust port is tested against (`rake lexbor`).
|
|
263
266
|
|
|
264
267
|
## Build (development)
|
|
265
268
|
|
data/lib/makiri/3.2/makiri.so
CHANGED
|
Binary file
|
data/lib/makiri/3.3/makiri.so
CHANGED
|
Binary file
|
data/lib/makiri/3.4/makiri.so
CHANGED
|
Binary file
|
data/lib/makiri/4.0/makiri.so
CHANGED
|
Binary file
|
data/lib/makiri/version.rb
CHANGED
|
@@ -28,30 +28,33 @@ module Makiri
|
|
|
28
28
|
# After #key?, which #has_attribute? aliases.
|
|
29
29
|
ReaderAliases.define_on(self)
|
|
30
30
|
|
|
31
|
-
# CSS selector queries over XML,
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
31
|
+
# CSS selector queries over XML, matched by the same engine as HTML's,
|
|
32
|
+
# as a browser's querySelectorAll matches them in an XML document: names
|
|
33
|
+
# and values compare as written, a type selector without a prefix
|
|
34
|
+
# matches its name in any namespace, and the context node's ancestors
|
|
35
|
+
# take part in the match while only its descendants are returned. An
|
|
36
|
+
# +ns+ hash of {prefix => uri} declares the prefixes the selector may
|
|
37
|
+
# use; its "xmlns" entry, if any, is the default namespace a bare type
|
|
38
|
+
# selector is then in.
|
|
37
39
|
#
|
|
38
|
-
# doc.css("entry")
|
|
39
|
-
# doc.css("a|entry", "a" => uri)
|
|
40
|
+
# doc.css("entry") # <entry> in any namespace
|
|
41
|
+
# doc.css("a|entry", "a" => uri) # <entry> in uri
|
|
42
|
+
# doc.css("entry", "xmlns" => uri) # the same, as a default
|
|
40
43
|
#
|
|
41
44
|
# @return [Makiri::NodeSet]
|
|
42
45
|
def css(selector, ns = nil)
|
|
43
|
-
_css(selector.to_s,
|
|
46
|
+
_css(selector.to_s, ns)
|
|
44
47
|
end
|
|
45
48
|
|
|
46
49
|
# First descendant matching +selector+, or nil. @return [Makiri::Node, nil]
|
|
47
50
|
def at_css(selector, ns = nil)
|
|
48
|
-
_at_css(selector.to_s,
|
|
51
|
+
_at_css(selector.to_s, ns)
|
|
49
52
|
end
|
|
50
53
|
|
|
51
54
|
# Whether this node matches +selector+ (full selector, combinators included).
|
|
52
55
|
# @return [Boolean]
|
|
53
56
|
def matches?(selector, ns = nil)
|
|
54
|
-
_css_matches(selector.to_s,
|
|
57
|
+
_css_matches(selector.to_s, ns)
|
|
55
58
|
end
|
|
56
59
|
|
|
57
60
|
private
|
|
@@ -61,25 +64,6 @@ module Makiri
|
|
|
61
64
|
def unprefixed_element_namespace
|
|
62
65
|
nil
|
|
63
66
|
end
|
|
64
|
-
|
|
65
|
-
# Build the {prefix => uri} hash the native primitives register. Matching
|
|
66
|
-
# Nokogiri: with NO explicit namespaces the document's own declarations are
|
|
67
|
-
# collected (the default namespace under the synthetic prefix "xmlns", so a
|
|
68
|
-
# bare type selector binds to it - the RSS/Atom common case); but once the
|
|
69
|
-
# caller passes a namespaces hash, ONLY those prefixes are used and a bare
|
|
70
|
-
# selector resolves to no namespace (Nokogiri disables the default binding
|
|
71
|
-
# the moment an explicit map is given). Reading only the root's
|
|
72
|
-
# declarations is O(root attributes), not the whole-document walk.
|
|
73
|
-
def _css_namespaces(user)
|
|
74
|
-
return user.transform_keys(&:to_s).transform_values(&:to_s) if user && !user.empty?
|
|
75
|
-
|
|
76
|
-
reg = {}
|
|
77
|
-
root = document&.root
|
|
78
|
-
root&.namespace_definitions&.each do |ns|
|
|
79
|
-
reg[ns.prefix.nil? ? "xmlns" : ns.prefix] = ns.href
|
|
80
|
-
end
|
|
81
|
-
reg
|
|
82
|
-
end
|
|
83
67
|
end
|
|
84
68
|
end
|
|
85
69
|
end
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
Lexbor SUBCOMPONENTS:
|
|
181
|
+
|
|
182
|
+
The Lexbor includes a number of subcomponents with
|
|
183
|
+
separate copyright notices and license terms. Your use of the source
|
|
184
|
+
code for the these subcomponents is subject to the terms and
|
|
185
|
+
conditions of the following licenses. Paths are relative to the lexbor
|
|
186
|
+
folder.
|
|
187
|
+
|
|
188
|
+
Portions of source/lexbor/core/dtoa.h, source/lexbor/core/dtoa.c,
|
|
189
|
+
source/lexbor/core/strtod.h, source/lexbor/core/strtod.c,
|
|
190
|
+
source/lexbor/core/diyfp.h, source/lexbor/core/diyfp.c is based on
|
|
191
|
+
NGINX NJS project (https://github.com/nginx/njs/) which is
|
|
192
|
+
available under BSD 2-clause "Simplified" License.
|
|
193
|
+
|
|
194
|
+
BSD-2-Clause license.
|
|
195
|
+
|
|
196
|
+
Copyright (C) 2015-2019 NGINX, Inc.
|
|
197
|
+
Copyright (C) 2019-2025 F5, Inc.
|
|
198
|
+
Copyright (C) 2015-2021 Igor Sysoev
|
|
199
|
+
Copyright (C) 2017-2025 Dmitry Volyntsev
|
|
200
|
+
Copyright (C) 2019-2022 Alexander Borisov
|
|
201
|
+
Copyright (C) 2022-2025 Vadim Zhestikov
|
|
202
|
+
All rights reserved.
|
|
203
|
+
|
|
204
|
+
Redistribution and use in source and binary forms, with or without
|
|
205
|
+
modification, are permitted provided that the following conditions
|
|
206
|
+
are met:
|
|
207
|
+
1. Redistributions of source code must retain the above copyright
|
|
208
|
+
notice, this list of conditions and the following disclaimer.
|
|
209
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
210
|
+
notice, this list of conditions and the following disclaimer in the
|
|
211
|
+
documentation and/or other materials provided with the distribution.
|
|
212
|
+
|
|
213
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
214
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
215
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
216
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
217
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
218
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
219
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
220
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
221
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
222
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
223
|
+
SUCH DAMAGE.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
Lexbor.
|
|
3
|
+
|
|
4
|
+
Copyright 2018-2020 Alexander Borisov
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License.
|
|
8
|
+
You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
See the License for the specific language governing permissions and
|
|
16
|
+
limitations under the License.
|