|
1 | 1 | <?php
|
2 | 2 | /*
|
3 |
| - * html2canvas-php-proxy 1.0.0 |
| 3 | + * html2canvas-php-proxy 1.1.0 |
4 | 4 | *
|
5 | 5 | * Copyright (c) 2018 Guilherme Nascimento ([email protected])
|
6 | 6 | *
|
|
19 | 19 | define('H2CP_DATAURI', false); // Enable use of "data URI scheme"
|
20 | 20 | define('H2CP_PREFER_CURL', true); // Enable curl if avaliable or disable
|
21 | 21 | define('H2CP_SECPREFIX', 'h2cp_'); // Prefix temp filename
|
22 |
| -define('H2CP_ALLOWED_DOMAINS', array( '*' )); // * allow all domains, *.site.com for sub-domains, or fixed domains use array( 'site.com', 'www.site.com' ) |
23 |
| -define('H2CP_ALLOWED_PORTS', array( 80, 443 )); // Allowed ports |
| 22 | +define('H2CP_ALLOWED_DOMAINS', '*'); // * allow all domains, *.site.com for sub-domains, or fixed domains use array( 'site.com', 'www.site.com' ) |
| 23 | +define('H2CP_ALLOWED_PORTS', '80,443'); // Allowed ports |
24 | 24 |
|
25 | 25 | /*
|
26 | 26 | * Set false for disable SSL check
|
@@ -347,7 +347,9 @@ function isHttpUrl($url)
|
347 | 347 | function isAllowedUrl($url, &$message) {
|
348 | 348 | $uri = parse_url($url);
|
349 | 349 |
|
350 |
| - if (in_array('*', H2CP_ALLOWED_DOMAINS) === false) { |
| 350 | + $domains = array_map('trim', explode(',', H2CP_ALLOWED_DOMAINS)); |
| 351 | + |
| 352 | + if (in_array('*', $domains) === false) { |
351 | 353 | $ok = false;
|
352 | 354 |
|
353 | 355 | foreach (H2CP_ALLOWED_DOMAINS as $domain) {
|
@@ -379,25 +381,12 @@ function isAllowedUrl($url, &$message) {
|
379 | 381 | $port = $uri['port'];
|
380 | 382 | }
|
381 | 383 |
|
382 |
| - $ok = false; |
| 384 | + $ports = array_map('trim', explode(',', H2CP_ALLOWED_PORTS)); |
383 | 385 |
|
384 |
| - foreach (H2CP_ALLOWED_PORTS as $allowed_port) { |
385 |
| - if ($port == $allowed_port) { |
386 |
| - $ok = true; |
387 |
| - break; |
388 |
| - } |
389 |
| - } |
390 |
| - |
391 |
| - if ($ok) { |
| 386 | + if (in_array($port, $ports)) { |
392 | 387 | return true;
|
393 | 388 | }
|
394 | 389 |
|
395 |
| - if (empty($uri['port'])) { |
396 |
| - $port = strcasecmp('https', $uri['scheme']) === 0 ? 443 : 80; |
397 |
| - } else { |
398 |
| - $port = $uri['port']; |
399 |
| - } |
400 |
| - |
401 | 390 | $message = '"' . $port . '" port is not allowed';
|
402 | 391 |
|
403 | 392 | return false;
|
|
0 commit comments