Skip to content

Commit 67aafe7

Browse files
MarkVaughnfinwe
authored andcommitted
Skip non supported URL schemes in GetFullPath
1 parent ff852a4 commit 67aafe7

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ mPDF 8.0.x
2121
* Fixed skipping ordered list numbering with page-break-inside: avoid (#339)
2222
* Compound classes selector support, like `.one.two` or `div.message.special` (#538, @peterdevpl)
2323
* Fixed CMYK colors in text-shadow (#1115, @lexilya)
24+
* Skip non supported wrappers when resolving paths (#1204, @MarkVaughn)
2425

2526
mPDF 8.0.0
2627
===========================

src/Mpdf.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11425,7 +11425,10 @@ public function GetFullPath(&$path, $basepath = '')
1142511425
return;
1142611426
}
1142711427

11428-
if (preg_match('@^(mailto|tel|fax):.*@i', $path)) {
11428+
// Skip schemes not supported by installed stream wrappers
11429+
$wrappers = stream_get_wrappers();
11430+
$pattern = sprintf('@^(?!%s)[a-z0-9\.\-+]+:.*@i', implode('|', $wrappers));
11431+
if (preg_match($pattern, $path)) {
1142911432
return;
1143011433
}
1143111434

tests/Issues/Issue1204Test.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Issues;
4+
5+
class Issue1204Test extends \PHPUnit_Framework_TestCase
6+
{
7+
8+
/**
9+
* Addresses Issue:
10+
*
11+
* is_file(): Unable to find the wrapper "chrome-extension" - did you forget to enable it when you configured PHP?
12+
*
13+
* @throws \Mpdf\MpdfException
14+
*/
15+
public function testIgnoresNonHttpURIs()
16+
{
17+
$mpdf = new \Mpdf\Mpdf();
18+
19+
$mpdf->WriteHTML('<a href="chrome-extension://fooobarextension"></a>');
20+
$mpdf->WriteHTML('<img src="chrome-extension://fooobarextension">');
21+
}
22+
23+
}

0 commit comments

Comments
 (0)