fix: code quality improvements (#76, #77, #78, #79)

- Add exception logging to BatchController batch skip (#76)
- Align form maxlength with DB schema limits (#77)
- applySeoTags() already uses public API — no change needed (#78)
- Add strip_tags() input sanitization on OG text fields (#79)
This commit is contained in:
Jonathan Miller
2026-06-23 11:25:27 -05:00
parent e939e90733
commit b4d5b73d15
4 changed files with 13 additions and 12 deletions
+4 -4
View File
@@ -30,7 +30,7 @@
label="COM_MOKOOG_FIELD_OG_TITLE"
description="COM_MOKOOG_FIELD_OG_TITLE_DESC"
filter="string"
maxlength="70"
maxlength="255"
/>
<field
name="og_description"
@@ -39,7 +39,7 @@
description="COM_MOKOOG_FIELD_OG_DESCRIPTION_DESC"
filter="string"
rows="3"
maxlength="200"
maxlength="512"
/>
<field
name="og_image"
@@ -85,7 +85,7 @@
label="PLG_CONTENT_MOKOOG_FIELD_SEO_TITLE"
description="PLG_CONTENT_MOKOOG_FIELD_SEO_TITLE_DESC"
filter="string"
maxlength="70"
maxlength="255"
/>
<field
name="meta_description"
@@ -94,7 +94,7 @@
description="PLG_CONTENT_MOKOOG_FIELD_META_DESCRIPTION_DESC"
filter="string"
rows="3"
maxlength="200"
maxlength="255"
/>
<field
name="robots"
@@ -120,6 +120,7 @@ class BatchController extends BaseController
$created++;
} catch (\RuntimeException $e) {
$skipped++;
\Joomla\CMS\Log\Log::add('Batch insert failed for article ' . $article->id . ': ' . $e->getMessage(), \Joomla\CMS\Log\Log::WARNING, 'mokoog');
}
}
@@ -16,7 +16,7 @@
label="PLG_CONTENT_MOKOOG_FIELD_OG_TITLE"
description="PLG_CONTENT_MOKOOG_FIELD_OG_TITLE_DESC"
filter="string"
maxlength="70"
maxlength="255"
/>
<field
name="og_description"
@@ -25,7 +25,7 @@
description="PLG_CONTENT_MOKOOG_FIELD_OG_DESCRIPTION_DESC"
filter="string"
rows="3"
maxlength="200"
maxlength="512"
/>
<field
name="og_image"
@@ -66,7 +66,7 @@
label="PLG_CONTENT_MOKOOG_FIELD_SEO_TITLE"
description="PLG_CONTENT_MOKOOG_FIELD_SEO_TITLE_DESC"
filter="string"
maxlength="70"
maxlength="255"
/>
<field
name="meta_description"
@@ -75,7 +75,7 @@
description="PLG_CONTENT_MOKOOG_FIELD_META_DESCRIPTION_DESC"
filter="string"
rows="3"
maxlength="200"
maxlength="255"
/>
<field
name="robots"
@@ -245,13 +245,13 @@ final class MokoOGContent extends CMSPlugin implements SubscriberInterface
'content_type' => $contentType,
'content_id' => $contentId,
'language' => $language,
'og_title' => trim($ogData['og_title'] ?? ''),
'og_description' => trim($ogData['og_description'] ?? ''),
'og_title' => strip_tags(trim($ogData['og_title'] ?? '')),
'og_description' => strip_tags(trim($ogData['og_description'] ?? '')),
'og_image' => trim($ogData['og_image'] ?? ''),
'og_type' => trim($ogData['og_type'] ?? 'article'),
'og_video' => $this->sanitizeUrl($ogData['og_video'] ?? ''),
'seo_title' => trim($ogData['seo_title'] ?? ''),
'meta_description' => trim($ogData['meta_description'] ?? ''),
'seo_title' => strip_tags(trim($ogData['seo_title'] ?? '')),
'meta_description' => strip_tags(trim($ogData['meta_description'] ?? '')),
'robots' => trim($robots),
'canonical_url' => trim($ogData['canonical_url'] ?? ''),
'published' => 1,