diff --git a/include/admin/Layout.php b/include/admin/Layout.php
index 45887e6..4b84489 100644
--- a/include/admin/Layout.php
+++ b/include/admin/Layout.php
@@ -1979,17 +1979,17 @@ class Layout extends \gp\admin\Addon\Install{
return $theme;
}
+ public function TitlesCount($layout) {
+ $titles_count = 0;
- public function TitlesCount($layout){
- $titles_count = 0;
- foreach($this->LayoutArray as $layout_comparison){
- if( $layout == $layout_comparison ){
- $titles_count++;
- }
- }
- return $titles_count;
- }
+ foreach ($this->LayoutArray ?? [] as $layout_comparison) {
+ if ($layout == $layout_comparison) {
+ $titles_count++;
+ }
+ }
+ return $titles_count;
+ }
/**
* Restore a layout to it's default content arrangement
diff --git a/include/tool/Editing.php b/include/tool/Editing.php
index 794ac87..878c52c 100644
--- a/include/tool/Editing.php
+++ b/include/tool/Editing.php
@@ -1000,22 +1000,31 @@ namespace gp\tool{
echo '
';
- foreach($_POST['images'] as $i => $image ){
+ foreach ($_POST['images'] as $i => $image) {
+ // Sanitize and escape the image path
+ $image = htmlspecialchars($image, ENT_QUOTES, 'UTF-8');
- $thumb_path = \gp\tool::ThumbnailPath($image);
- $caption = $_POST['captions'][$i];
- \gp\tool\Files::cleanText($caption);
- $img_alt = str_replace('_', ' ', basename(pathinfo($image, PATHINFO_FILENAME)));
+ // Generate a thumbnail path (assumes this function is safe)
+ $thumb_path = \gp\tool::ThumbnailPath($image);
+ $thumb_path = htmlspecialchars($thumb_path, ENT_QUOTES, 'UTF-8');
- echo '- ';
- // echo ''; // title="'.htmlspecialchars($caption).'"
- echo '';
- echo '
';
- echo ''.$caption.'';
- echo '';
- echo ' ';
- }
- echo '
';
+ // Get and escape captions
+ $caption = isset($_POST['captions'][$i]) ? $_POST['captions'][$i] : '';
+ \gp\tool\Files::cleanText($caption); // Assuming this cleans text correctly
+ $caption = htmlspecialchars($caption, ENT_QUOTES, 'UTF-8');
+
+ // Sanitize the alt text
+ $img_alt = htmlspecialchars(str_replace('_', ' ', basename(pathinfo($image, PATHINFO_FILENAME))), ENT_QUOTES, 'UTF-8');
+
+ echo '';
+ echo '';
+ echo '
';
+ echo '' . $caption . '';
+ echo '';
+ echo '';
+ }
+
+ echo '';
$section['content'] = ob_get_clean();
$section['images'] = $_POST['images'];