i18n tools: In StringExtractor don't strip slashes from URLs.

Props SergeyBiryukov, ocean90.
Fixes #36015.

git-svn-id: https://develop.svn.wordpress.org/trunk@36781 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2016-02-29 20:44:31 +00:00
parent 5f808bd8fc
commit f8af8cdc6c
2 changed files with 33 additions and 1 deletions

View File

@ -172,7 +172,7 @@ class StringExtractor {
if ( T_COMMENT == $id ) {
$text = preg_replace( '%^\s+\*\s%m', '', $text );
$text = str_replace( array( "\r\n", "\n" ), ' ', $text );;
$text = trim( preg_replace( '%^/\*|//%', '', preg_replace( '%\*/$%', '', $text ) ) );
$text = trim( preg_replace( '%^(/\*|//)%', '', preg_replace( '%\*/$%', '', $text ) ) );
if ( 0 === stripos( $text, $this->comment_prefix ) ) {
$latest_comment = $text;
}

View File

@ -183,6 +183,38 @@ class ExtractTest extends PHPUnit_Framework_TestCase {
);
}
/**
* @group comment
*/
function test_find_function_calls_with_c_style_comment() {
$this->assertEquals( array( array(
'name' => '__', 'args' => array( 'on' ), 'line' => 3,
'comment' => 'translators: let your ears fly!'
) ),
$this->extractor->find_function_calls( array( '__' ),
"<?php
// translators: let your ears fly!
__( 'on' );"
)
);
}
/**
* @group comment
*/
function test_find_function_calls_with_url_in_comment() {
$this->assertEquals( array( array(
'name' => '__', 'args' => array( 'F j, Y g:i a' ), 'line' => 3,
'comment' => 'translators: localized date and time format, see http://php.net/date'
) ),
$this->extractor->find_function_calls( array( '__' ),
"<?php
/* translators: localized date and time format, see http://php.net/date */
__( 'F j, Y g:i a' );"
)
);
}
/**
* @group comment
*/