Răsfoiți Sursa

attempt fix for test iframe

CauseFX 4 ani în urmă
părinte
comite
a8d7d3713f
1 a modificat fișierele cu 15 adăugiri și 1 ștergeri
  1. 15 1
      api/functions/organizr-functions.php

+ 15 - 1
api/functions/organizr-functions.php

@@ -500,16 +500,30 @@ trait OrganizrFunctions
 	public function checkFrame($array, $url)
 	{
 		if (array_key_exists("x-frame-options", $array)) {
+			$array['x-frame-options'] = strtolower($array['x-frame-options']);
 			if ($array['x-frame-options'] == "deny") {
 				return false;
 			} elseif ($array['x-frame-options'] == "sameorgin") {
 				$digest = parse_url($url);
-				$host = (isset($digest['host']) ? $digest['host'] : '');
+				$host = ($digest['host'] ?? '');
 				if ($this->getServer() == $host) {
 					return true;
 				} else {
 					return false;
 				}
+			} elseif (strpos($array['x-frame-options'], 'allow-from') !== false) {
+				$explodeServers = explode(' ', $array['x-frame-options']);
+				$allowed = false;
+				foreach ($explodeServers as $server) {
+					$digest = parse_url($server);
+					$host = ($digest['host'] ?? '');
+					if ($this->getServer() == $host) {
+						$allowed = true;
+					}
+				}
+				return $allowed;
+			} else {
+				return false;
 			}
 		} else {
 			if (!$array) {