church-api/verify_and_clean.sql
Benjamin Slingo 0c06e159bb Initial commit: Church API Rust implementation
Complete church management system with bulletin management, media processing, live streaming integration, and web interface. Includes authentication, email notifications, database migrations, and comprehensive test suite.
2025-08-19 20:56:41 -04:00

102 lines
3.2 KiB
SQL

-- First, let's check what data actually contains HTML
SELECT 'Bulletins with HTML tags:' as check_type;
SELECT id, title,
CASE WHEN scripture_reading LIKE '%<%' THEN 'HAS HTML' ELSE 'CLEAN' END as scripture_status,
CASE WHEN sabbath_school LIKE '%<%' THEN 'HAS HTML' ELSE 'CLEAN' END as sabbath_status,
CASE WHEN divine_worship LIKE '%<%' THEN 'HAS HTML' ELSE 'CLEAN' END as worship_status
FROM bulletins
WHERE is_active = true
ORDER BY date DESC
LIMIT 3;
-- Show actual content to see what we're dealing with
SELECT 'Current scripture_reading content:' as content_type;
SELECT substring(scripture_reading, 1, 100) as sample_content
FROM bulletins
WHERE is_active = true
ORDER BY date DESC
LIMIT 1;
-- Now let's clean it more aggressively
UPDATE bulletins
SET scripture_reading =
TRIM(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REGEXP_REPLACE(scripture_reading, '<[^>]*>', '', 'g'),
'&amp;', '&'
),
'&lt;', '<'
),
'&gt;', '>'
),
'&quot;', '"'
),
'&#39;', ''''
),
'&nbsp;', ' '
)
),
sabbath_school =
CASE WHEN sabbath_school IS NOT NULL THEN
TRIM(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REGEXP_REPLACE(sabbath_school, '<[^>]*>', '', 'g'),
'&amp;', '&'
),
'&lt;', '<'
),
'&gt;', '>'
),
'&quot;', '"'
),
'&#39;', ''''
),
'&nbsp;', ' '
)
)
ELSE sabbath_school END,
divine_worship =
CASE WHEN divine_worship IS NOT NULL THEN
TRIM(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REPLACE(
REGEXP_REPLACE(divine_worship, '<[^>]*>', '', 'g'),
'&amp;', '&'
),
'&lt;', '<'
),
'&gt;', '>'
),
'&quot;', '"'
),
'&#39;', ''''
),
'&nbsp;', ' '
)
)
ELSE divine_worship END
WHERE scripture_reading LIKE '%<%'
OR sabbath_school LIKE '%<%'
OR divine_worship LIKE '%<%';
-- Verify the cleaning worked
SELECT 'After cleaning - scripture_reading content:' as content_type;
SELECT substring(scripture_reading, 1, 100) as sample_content
FROM bulletins
WHERE is_active = true
ORDER BY date DESC
LIMIT 1;