php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58842 newt_entry_set_filter don't work special character (i.e. backspace)
Submitted: 2009-08-31 04:15 UTC Modified: 2009-11-04 11:33 UTC
From: sg at efficientip dot com Assigned:
Status: Closed Package: newt (PECL)
PHP Version: 5.2.10 OS: FreeBSD 7.2
Private report: No CVE-ID: None
 [2009-08-31 04:15 UTC] sg at efficientip dot com
Description:
------------
newt_entry_set_filter work only with ascii characters

Reproduce code:
---------------
create a newt entry and assign a filter:


<php?

// newt init + create entry
// ....

newt_entry_set_filter($entry_obj,'filter_ip',NULL);

function filter_ip($obj,$param,$char,$cursor)
{
    return($char);
}

?>

This bug come from the cast from integer to a single character in newt_entry_filter_callback_wrapper function.
The following patch correct the issue:

*** newt.c      Mon Aug 31 09:43:25 2009
--- newt.c.patch        Mon Aug 31 09:43:09 2009
***************
*** 619,625 ****

        /* Third parameter is single character */
        MAKE_STD_ZVAL (args[2]);
!       ZVAL_STRING (args[2], (char *)&ch, 1);

        /* Fourth parameter is integer  */
        MAKE_STD_ZVAL (args[3]);
--- 619,625 ----

        /* Third parameter is single character */
        MAKE_STD_ZVAL (args[2]);
!       ZVAL_LONG (args[2],ch);

        /* Fourth parameter is integer  */
        MAKE_STD_ZVAL (args[3]);



Expected result:
----------------
backspace should work (right/left arrows too)

Actual result:
--------------
backspace and arrows don't work

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-22 11:19 UTC] spektom at gmail dot com
Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at
http://pecl.php.net/get/newt


 [2009-09-22 11:59 UTC] sg at efficientip dot com
Latest release (1.2.3) don't correct the issue.
The 3rd parameter is still a single character.
Special character are not correctly passed to the wrapper function. The 3rd parameter must be a long.
 [2009-09-23 10:34 UTC] spektom at gmail dot com
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PECL.


Can you provide a code example for re-production?
Thanks!
 [2009-09-23 12:01 UTC] sg at efficientip dot com
Here is a sample code:

<?php

newt_init();
newt_cls();

newt_centered_window(40,10,"Testing");

$form = newt_form();
$text = newt_entry(4,4,15,'',NEWT_ENTRY_RETURNEXIT);
newt_form_add_component($form,$text);
newt_entry_set_filter($text,'filter_text',NULL);

do
  {
    newt_refresh();

    $exit_param = array();
    newt_form_run($form,$exit_param);

    switch($exit_param['reason'])
      {
      case NEWT_EXIT_HOTKEY:
        $do_loop = FALSE;
        break;
      }
  }
 while($do_loop == TRUE);

newt_pop_window();
newt_finished();
exit();

function filter_text($obj,$param,$char,$cursor)
{
  // accept all characters
  return($char);
}


Try to enter a backspace or move the cursor using arrows.
 [2009-11-04 11:33 UTC] spektom at gmail dot com
Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at
http://pecl.php.net/get/newt


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 06:01:29 2024 UTC