Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP: Escaped quotes not recognised correctly #2105

Closed
Krinkle opened this issue Apr 5, 2022 · 1 comment
Closed

PHP: Escaped quotes not recognised correctly #2105

Krinkle opened this issue Apr 5, 2022 · 1 comment

Comments

@Krinkle
Copy link

Krinkle commented Apr 5, 2022

The string is currently terminated after the third quote in "foo \"$bar\" baz" instead of at the end.

Source:

<?php
if ( extension_loaded( 'excimer' ) && isset( $_GET['forceflame'] ) ) {
	$prof = new ExcimerProfiler();
	$prof->setPeriod( 0.1 / 1000 ); // Every 0.1ms
	$prof->setEventType( EXCIMER_REAL );
	$prof->start();
	register_shutdown_function( function () use ( $prof ) {
		$prof->stop();
		$title = MW_ENTRY_POINT . '.php ' . gmdate( 'Y-m-d H:i:s' ) . ' UTC';
		$pipe = popen( "/usr/local/bin/flamegraph.pl --title=\"$title\" > /var/www/html/w/docs/flamegraph.svg", 'w' );
		fwrite( $pipe, $prof->getLog()->formatCollapsed() );
	} );
}

Pygments:

Screenshot 2022-04-06 at 00 00 47

Downstream: https://www.mediawiki.org/w/index.php?title=MediaWiki-Docker/Configuration_recipes/Profiling&oldid=5148799

Minimal demo:

<?php
$title = 'UTC';
$pipe = popen( "flamegraph.pl --title=\"$title\" > /var/www/html/w/docs/flamegraph.svg", 'w' );
fwrite( $pipe, $prof->getLog()->formatCollapsed() );

Screenshot 2022-04-06 at 00 38 41

https://pygments.org/demo/?lexer=php&style=xcode&formatter=html&code=%3C%3Fphp%0A%24title+%3D+%27UTC%27%3B%0A%24pipe+%3D+popen%28+%22flamegraph.pl+--title%3D%5C%22%24title%5C%22+%3E+%2Fvar%2Fwww%2Fhtml%2Fw%2Fdocs%2Fflamegraph.svg%22%2C+%27w%27+%29%3B%0Afwrite%28+%24pipe%2C+%24prof-%3EgetLog%28%29-%3EformatCollapsed%28%29+%29%3B

@birkenfeld
Copy link
Member

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants