bugGNU gettext - Bugs: bug #62158, PHP indented heredoc ending marker...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #62158: PHP indented heredoc ending marker are not handled correctly

Submitter:  Cédric Anne <canne>
Submitted:  Wed 09 Mar 2022 09:27:19 AM UTC
 
Category:  PHP Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Thu 26 Jan 2023 11:36:39 PM UTC, comment #2: 

Thanks for the report and patch. I'll look at it in a month or two.

> I just spent 1 hours trying to compile the lib without success

To compile a GNU package, the simplest way it to download a tarball from ftp.gnu.org, unpack it, look at the DEPENDENCIES and INSTALL files, then run

./configure --prefix=/some/dir
make
make check
make install

Bruno Haible <haible>
Project Administrator
Thu 26 Jan 2023 09:40:06 PM UTC, comment #1: 

As far as I understand the code, maybe the fix could be simple as proposed in following diff.
Anyway, I do not have any skills in C development and I just spent 1 hours trying to compile the lib without success, so any help would be appreciated.

```diff gettext-tools/src/x-php.c
diff --git a/gettext-tools/src/x-php.c b/gettext-tools/src/x-php.c
index 78cce8e1d..e247d8fa7 100644
--- a/gettext-tools/src/x-php.c
+++ b/gettext-tools/src/x-php.c
@@ -1203,6 +1203,8 @@ phase4_get (token_ty *tp)
                             while (bufidx < bufpos)
                               {
                                 c = phase1_getc ();
+                                if (c == ' ')
+                                  continue;
                                 if (c == EOF)
                                   break;
                                 if (c != buffer[bufidx])
```

Cédric Anne <canne>
Wed 09 Mar 2022 09:27:19 AM UTC, original submission:  

When PHP code contains heredoc ending markers that are indented (available since PHP 7.3), it seems that it is not detected. Result is that strings located in following code source are not extracted.

See in joined file (test.php).
- The heredoc block that starts on line 6 should end on line 8, but its ending marker is indented and not detected.
- String on line 11 is ignored, as considered in a heredoc block.
- The heredoc ending marker on line 16 is taken for ending marker of previous heredoc block, as it has the same name.
- The heredoc block that starts on line 22 should end on line 24, but its ending marker is indented and not detected.
- String on line 27 is ignored, as considered in a heredoc block.
- The heredoc ending marker on line 32 has no effect, as it has a different name than previous heredoc block.

Attached test.po file was generated using following command line:
xgettext test.php -L PHP --force-po --keyword=_:1 -o test.po

Cédric Anne <canne>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #52973:  test.php added by canne (391B - application/x-php)
file #52974:  test.po added by canne (663B - text/x-gettext-translation)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by haible (Posted a comment)
  • -email is unavailable- added by canne (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

     

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-03-09 canne Attached File- Added test.php, #52973
        Attached File- Added test.po, #52974

    Back to the top

    Powered by Savane 3.10