]> git.ipfire.org Git - thirdparty/gettext.git/commit
xgettext: PHP: Fix parsing of strings and heredocs with embedded expressions.
authorBruno Haible <bruno@clisp.org>
Wed, 28 Jan 2026 12:50:21 +0000 (13:50 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 28 Jan 2026 12:50:21 +0000 (13:50 +0100)
commit053b5ef04dcdd077d66ed91470432be8c9c8a49e
tree2929628fe73c993ede64fb82f25ccfdb2e60f13e
parentb093401bea2957237253364f63861725f7cc7fe2
xgettext: PHP: Fix parsing of strings and heredocs with embedded expressions.

Reported by Gert Jan Schoneveld <gertjan@facilityapps.com> in
<https://lists.gnu.org/archive/html/bug-gettext/2025-08/msg00007.html>
and by Benoit Waldmann <benoit.waldmann@siagilus.fr>
at <https://savannah.gnu.org/bugs/index.php?item_id=67948>.

* gettext-tools/src/x-php.c (enum token_type_ty): New enum values
token_type_lbrace, token_type_rbrace.
(struct php_extractor): New field brace_nesting_depth.
(php_extractor_init_rest): Initialize it.
(extract_balanced): Forward-declare.
(process_dquote_or_heredoc): Change handling of embedded expressions.
(phase4_get): Recognize token_type_lbrace, token_type_rbrace.
(extract_balanced): Recurse also for token_type_lbrace.
(extract_php_input): Remove function.
(extract_php): Inline it here.
* gettext-tools/tests/xgettext-php-1: Add more tests of embedded expressions.
gettext-tools/src/x-php.c
gettext-tools/tests/xgettext-php-1