An experimental web framework where PostgreSQL does everything: routing, HTML, file storage, jobs and sessions.
fix_all_format_escaping.sql · 1.3 KB · 40 lines
| 1 | -- Fix ALL format() escaping issues in handle_request function |
| 2 | -- Need to escape % characters and also handle the closing parenthesis issue |
| 3 | |
| 4 | UPDATE code_files |
| 5 | SET content = replace( |
| 6 | replace( |
| 7 | replace( |
| 8 | replace( |
| 9 | replace( |
| 10 | replace(content, |
| 11 | '100%)', '100%%'), -- Fix closing paren with percent |
| 12 | '0%,', '0%%,'), -- Fix percent with comma |
| 13 | '100%%;', '100%%;'), -- Keep already escaped ones |
| 14 | '0%%,', '0%%,'), -- Keep already escaped ones |
| 15 | 'width: 100%', 'width: 100%%'), -- Fix width percentages |
| 16 | '100%%)', '100%%)') -- Ensure closing paren is fixed |
| 17 | ), |
| 18 | version = version + 1, |
| 19 | updated_at = now() |
| 20 | WHERE path = 'functions/handle_request.sql'; |
| 21 | |
| 22 | -- Manually reload since hot_reload has issues |
| 23 | \o /dev/null |
| 24 | SELECT content FROM code_files WHERE path = 'functions/handle_request.sql' \gset |
| 25 | \o |
| 26 | |
| 27 | -- Drop and recreate the function |
| 28 | DROP FUNCTION IF EXISTS handle_request(text, text, jsonb, jsonb, uuid); |
| 29 | |
| 30 | -- Execute the stored function definition |
| 31 | DO $$ |
| 32 | DECLARE |
| 33 | v_sql text; |
| 34 | BEGIN |
| 35 | SELECT content INTO v_sql FROM code_files WHERE path = 'functions/handle_request.sql'; |
| 36 | EXECUTE v_sql; |
| 37 | END $$; |
| 38 | |
| 39 | -- Return status |
| 40 | SELECT 'All format() escaping issues fixed and function reloaded!' as result; |