Merge pull request #13394 from calixteman/xml_parser
Handle PI with no value in xml parser
This commit is contained in:
commit
faf6b10939
@ -145,6 +145,7 @@ class XMLParserBase {
|
||||
pos < s.length &&
|
||||
!isWhitespace(s, pos) &&
|
||||
s[pos] !== ">" &&
|
||||
s[pos] !== "?" &&
|
||||
s[pos] !== "/"
|
||||
) {
|
||||
++pos;
|
||||
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { SimpleXMLParser, XMLParserBase } from "../../src/core/xml_parser.js";
|
||||
import { parseXFAPath } from "../../src/core/core_utils.js";
|
||||
import { SimpleXMLParser } from "../../src/core/xml_parser.js";
|
||||
|
||||
describe("XML", function () {
|
||||
describe("searchNode", function () {
|
||||
@ -108,4 +108,28 @@ describe("XML", function () {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("should parse processing instructions", function () {
|
||||
const xml = `
|
||||
<a>
|
||||
<?foo bar?>
|
||||
<?foo bar oof?>
|
||||
<?foo?>
|
||||
</a>`;
|
||||
const pi = [];
|
||||
|
||||
class MyParser extends XMLParserBase {
|
||||
onPi(name, value) {
|
||||
pi.push([name, value]);
|
||||
}
|
||||
}
|
||||
|
||||
new MyParser().parseXml(xml);
|
||||
|
||||
expect(pi).toEqual([
|
||||
["foo", "bar"],
|
||||
["foo", "bar oof"],
|
||||
["foo", ""],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user