php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47878 ScriptControl function capitalization discrepancy
Submitted: 2009-04-02 13:51 UTC Modified: 2020-02-07 13:55 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: csaba at alum dot mit dot edu Assigned: cmb (profile)
Status: Not a bug Package: COM related
PHP Version: 5.3.0RC1 OS: Win XP Pro
Private report: No CVE-ID: None
 [2009-04-02 13:51 UTC] csaba at alum dot mit dot edu
Description:
------------
It is possible to call a PHP function in a class that has been stuffed into a ScriptControl using the code below.  However, the name of the function must be given as lower case, which is probably not the intent.  This is especially odd when the original function's name contains capital letters.

Reproduce code:
---------------
<?php
// Demonstrates that caps in the function name
// leads to an error when calling a function within
// a class within a VBScript ScriptControl
// Related to http://bugs.php.net/bug.php?id=33386

class twoFuncs {
    public function Func1() { echo " func one\n"; }
    public function func2() { echo " func two\n"; } }
$clsInstTF = new twoFuncs;	// class instance

$oScript = new COM("MSScriptControl.ScriptControl");
$oScript->Language = "VBScript";
$oScript->AddObject ("tF", $clsInstTF, true);

$clsInstTF->func1();                        // OK
$clsInstTF->Func1();                        // OK
$oScript->ExecuteStatement ("tF.func1");    // OK
$oScript->ExecuteStatement ("tf.func1");    // OK
$oScript->ExecuteStatement ("tF.Func1");    // Error
?>

Expected result:
----------------
I expect so see " func one" repeated on five consecutive lines

Actual result:
--------------
" func one" is repeated four times, and on the 5th attempt an error results:
Object doesn't support this property or method: 'tF.Func1'

My guess is that what is happening is that when the function name is being matched, the actual function name is being lower cased while the function name being sought is not being lower cased.  Note that class instance in the VBScript script control is matched regardless of capitalization.

In contrast, if the language line is changed to:
$oScript->Language = "VBScript";
then 4th test line (tf.func1) should be commented out because JScript is case sensitive there.  But after that commenting out, the last line still errors.

This bug is similar to, but distinct from, bug 33386

Csaba Gabor from Vienna

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-07 13:55 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-02-07 13:55 UTC] cmb@php.net
While PHP method names are case-insensitive, what is accomplished
by storing lower-cased versions of the names in the method table
(and using lower-cased versions at the call site), COM method
names are case-sensitive.  Furthermore, there is no special
treatment from PHP of the string parameter of ExecuteStatement()
(or other string parameters of COM methods); these are passed
verbatim; however, the class name passed to AddObject() is treated by
COM according to the declared scripting language (VBScript or
JScript).

So, for VBScript, the string passed to ExecuteStatement() can have
the class name in either spelling, while the method name has to be
lower-cased.  For JScript, however, also the class name has to
match case-sensitively.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC