]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/OEmbed.php
Merge pull request #6201 from JonnyTischbein/feature_admin_subsubpages
[friendica.git] / src / Object / OEmbed.php
index 3eebcc22653d2b7c63aa983ad88ca231710a2c23..bd336f7583fb6c994da174bfe7b9584ed8ddcd49 100644 (file)
@@ -7,7 +7,7 @@ namespace Friendica\Object;
  *
  * @see https://oembed.com/#section2.3
  *
- * @author Hypolite Petovan <mrpetovan@gmail.com>
+ * @author Hypolite Petovan <hypolite@mrpetovan.com>
  */
 class OEmbed
 {
@@ -42,6 +42,17 @@ class OEmbed
                }
 
                foreach ($properties as $key => $value) {
+                       if (in_array($key, ['thumbnail_width', 'thumbnail_height', 'width', 'height'])) {
+                               // These values should be numbers, so ensure that they really are numbers.
+                               $value = (int)$value;
+                       } elseif ($key != 'html') {
+                               // Avoid being able to inject some ugly stuff through these fields.
+                               $value = htmlentities($value);
+                       } else {
+                               /// @todo Add a way to sanitize the html as well, possibly with an <iframe>?
+                               $value = mb_convert_encoding($value, 'HTML-ENTITIES', mb_detect_encoding($value));
+                       }
+
                        if (property_exists(__CLASS__, $key)) {
                                $this->{$key} = $value;
                        }