xref: /PHP-7.4/ext/dom/tests/bug54601.phpt (revision ded3d984)
1--TEST--
2Segfault when removing the Doctype node
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7$xml = <<< XML
8<?xml version='1.0' encoding='utf-8' ?>
9<!DOCTYPE set PUBLIC "-//OASIS//DTD DocBook XML V5.0//EN" "http://www.docbook.org/xml/5.0/dtd/docbook.dtd" [
10<!ENTITY foo '<foo>footext</foo>'>
11<!ENTITY bar '<bar>bartext</bar>'>
12]>
13<set>&foo;&bar;</set>
14XML;
15
16$doc = new DOMDocument();
17$doc->loadXML($xml, LIBXML_NOENT);
18$n = $doc->doctype;
19$doc->removeChild($n);
20echo get_class($n), "\n";
21print $doc->saveXML();
22?>
23===DONE===
24<?php exit(0); ?>
25--EXPECT--
26DOMDocumentType
27<?xml version="1.0" encoding="utf-8"?>
28<set><foo>footext</foo><bar>bartext</bar></set>
29===DONE===
30