]> _ Git - fluidbook_tools.git/commitdiff
wait #5903 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 2 May 2023 14:35:01 +0000 (16:35 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 2 May 2023 14:35:01 +0000 (16:35 +0200)
src/Links/Link.php

index 60edcdf432451f83894fc8b811d48ab983f419cc..10bab6da3761becc30c059ee5802c4731cfe02c0 100644 (file)
@@ -75,6 +75,9 @@ class Link {
 
     public $allowsAnimation = true;
 
+    protected static $_encryptedTypes = [14, 15, 35, 39];
+    protected static $_encryptedAttributes = ['image_rollover'];
+
     /**
      *
      * @var CompilerInterface
@@ -682,6 +685,9 @@ class Link {
      * @throws \SodiumException
      */
     public static function decryptLink($link) {
+        if (!in_array($link['type'], self::$_encryptedTypes)) {
+            return $link;
+        }
         foreach ($link as $attr => $item) {
             if (!str_starts_with($item, '///')) {
                 continue;
@@ -700,6 +706,7 @@ class Link {
     public static function decryptLinks($links) {
         $res = [];
         foreach ($links as $key => $link) {
+
             $res[$key] = self::decryptLink($link);
         }
         return $res;
@@ -718,14 +725,11 @@ class Link {
      * @throws SodiumException
      */
     public static function encryptLinkAttrs($link) {
-        $crypted = [13, 14, 35];
-
-        if (!isset($link['type']) || !in_array($link['type'], $crypted)) {
+        if (!isset($link['type']) || !in_array($link['type'], self::$_encryptedTypes)) {
             return $link;
         }
 
-        $attrs = ['image_rollover'];
-        foreach ($attrs as $attr) {
+        foreach (self::$_encryptedAttributes as $attr) {
             if (!isset($link[$attr])) {
                 continue;
             }