xref: /PHP-8.4/ext/xmlreader/tests/bug73246.phpt (revision acf27628)
1--TEST--
2Bug #73246 (XMLReader: encoding length not checked)
3--EXTENSIONS--
4xmlreader
5--FILE--
6<?php
7$reader = new XMLReader();
8try {
9    $reader->open(__FILE__, "UTF\0-8");
10} catch (ValueError $e) {
11    echo $e->getMessage(), "\n";
12}
13try {
14    $reader->XML('<?xml version="1.0"?><root/>', "UTF\0-8");
15} catch (ValueError $e) {
16    echo $e->getMessage(), "\n";
17}
18try {
19    XMLReader::fromStream(fopen('php://memory', 'r'), encoding: "UTF\0-8");
20} catch (ValueError $e) {
21    echo $e->getMessage(), "\n";
22}
23?>
24--EXPECT--
25XMLReader::open(): Argument #2 ($encoding) must not contain any null bytes
26XMLReader::XML(): Argument #2 ($encoding) must not contain any null bytes
27XMLReader::fromStream(): Argument #2 ($encoding) must not contain any null bytes
28