Skip to content

Commit 0d49cf4

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #66322: COMPersistHelper::SaveToFile can save to wrong location
2 parents 5d0ef4c + 5e2ea00 commit 0d49cf4

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ PHP NEWS
33

44
?? ??? ????, PHP 7.4.4
55

6+
- COM:
7+
. Fixed bug #66322 (COMPersistHelper::SaveToFile can save to wrong location).
8+
(cmb)
9+
610
- CURL:
711
. Fixed bug #79019 (Copied cURL handles upload empty file). (cmb)
812

ext/com_dotnet/com_persist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ CPH_METHOD(SaveToFile)
398398
RETURN_FALSE;
399399
}
400400

401-
olefilename = php_com_string_to_olestring(filename, strlen(fullpath), helper->codepage);
401+
olefilename = php_com_string_to_olestring(fullpath, strlen(fullpath), helper->codepage);
402402
efree(fullpath);
403403
}
404404
res = IPersistFile_Save(helper->ipf, olefilename, remember);

ext/com_dotnet/tests/bug66322.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Bug #66322 (COMPersistHelper::SaveToFile can save to wrong location)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
6+
try {
7+
new COM('Word.Application');
8+
} catch (com_exception $ex) {
9+
die('skip MS Word not available');
10+
}
11+
if (getenv("SKIP_SLOW_TESTS")) die('skip slow test');
12+
?>
13+
--FILE--
14+
<?php
15+
$w = new COM('Word.Application');
16+
$doc = $w->Documents->Add();
17+
$ph = new COMPersistHelper($doc);
18+
$filename = __DIR__ . '\\..\\' . basename(__DIR__) . '\\66322.docx';
19+
$ph->SaveToFile($filename);
20+
var_dump(file_exists($filename));
21+
$w->Quit();
22+
?>
23+
--EXPECT--
24+
bool(true)

0 commit comments

Comments
 (0)