askrobots / postblob Public

An experimental web framework where PostgreSQL does everything: routing, HTML, file storage, jobs and sessions.

0 downloads

postblob/fix_all_format_escaping.sql
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/postblob.git
HTTPS
https://gitstable.com/git/askrobots/postblob.git
SSH
ssh://git@gitstable.com:2222/askrobots/postblob.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 docs: Add screenshots to README ae44e69 1 year, 1 month ago History
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
4UPDATE code_files
5SET 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),
18version = version + 1,
19updated_at = now()
20WHERE path = 'functions/handle_request.sql';
21
22-- Manually reload since hot_reload has issues
23\o /dev/null
24SELECT content FROM code_files WHERE path = 'functions/handle_request.sql' \gset
25\o
26
27-- Drop and recreate the function
28DROP FUNCTION IF EXISTS handle_request(text, text, jsonb, jsonb, uuid);
29
30-- Execute the stored function definition
31DO $$
32DECLARE
33 v_sql text;
34BEGIN
35 SELECT content INTO v_sql FROM code_files WHERE path = 'functions/handle_request.sql';
36 EXECUTE v_sql;
37END $$;
38
39-- Return status
40SELECT 'All format() escaping issues fixed and function reloaded!' as result;