Skip to content

Commit 93e20b0

Browse files
committed
prevent embedding huge HTML docs in XML results
1 parent 9aee018 commit 93e20b0

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

tests/benchmarks/benchmarks/html-api/WpHtmlTagProcessorBench.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function bench_tag_processor_html_parsing( array $params ): void {
126126
}
127127

128128
public function set_up_html_tag_processor( array $params ): void {
129-
$this->processor = new WP_HTML_Tag_Processor( $params[0] );
129+
$this->processor = new WP_HTML_Tag_Processor( file_get_contents( $params[0] ) );
130130
}
131131

132132
/**
@@ -146,7 +146,7 @@ public function bench_html_fragment_parsing( array $params ): void {
146146
}
147147

148148
public function set_up_html_fragment_processor( array $params ): void {
149-
$this->processor = WP_HTML_Processor::create_fragment( $params[0] );
149+
$this->processor = WP_HTML_Processor::create_fragment( file_get_contents( $params[0] ) );
150150
}
151151

152152
/**
@@ -166,12 +166,12 @@ public function bench_html_full_parsing( array $params ): void {
166166
}
167167

168168
public function set_up_html_full_parser( array $params ): void {
169-
$this->processor = WP_HTML_Processor::create_full_parser( $params[0] );
169+
$this->processor = WP_HTML_Processor::create_full_parser( file_get_contents( $params[0] ) );
170170
}
171171

172172
public static function provide_html(): iterable {
173-
yield 'Empty string' => array( '' );
174-
yield 'Short doc' => array( '<h1>Hello, world!</h1>' );
175-
yield 'HTML Standard' => array( file_get_contents( DIR_BENCHMARKDATA . '/html-standard.html' ) );
173+
yield 'Empty string' => array( 'data://text/html,' );
174+
yield 'Short doc' => array( 'data://text/html,<h1>Hello, world!</h1>' );
175+
yield 'HTML Standard' => array( 'file://' . DIR_BENCHMARKDATA . '/html-standard.html' );
176176
}
177177
}

0 commit comments

Comments
 (0)