From f8af8cdc6cd3df9d0860ee0ae71e5339e0ac8464 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Mon, 29 Feb 2016 20:44:31 +0000 Subject: [PATCH] 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 --- tools/i18n/extract.php | 2 +- tools/i18n/t/ExtractTest.php | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/tools/i18n/extract.php b/tools/i18n/extract.php index db0c8b4916..023b28bc69 100644 --- a/tools/i18n/extract.php +++ b/tools/i18n/extract.php @@ -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; } diff --git a/tools/i18n/t/ExtractTest.php b/tools/i18n/t/ExtractTest.php index 25ae44098c..8a38f5c583 100644 --- a/tools/i18n/t/ExtractTest.php +++ b/tools/i18n/t/ExtractTest.php @@ -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( '__' ), + "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( '__' ), + "