Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2026-10-06 6bac54b555d27f1a85c1e4f011a6e7bd9111b0d0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
DO $$
BEGIN
    perform htp_appletopen('my_app=let.class&я', 100, 200, 'f');
    perform htp_appletclose();
    perform htp_blockquoteopen('1', '2', '3');
    perform htp_blockquoteclose();
    perform htp_blockquoteopen('s', '12.,3_-_321 Россия!', 'id="my_quote" !@#$%^&*( .');
    perform htp_blockquoteclose();
    perform htp_bodyopen('/images/background.gif.Стиль', 'Вася BGPROPERTIES="fixed"');
    perform htp_bodyclose();
    perform htp_dlistopen('hjv', 'class="my-definition-list"');
    perform htp_dlistclose();
    perform htp_formopen('/cgi-bin/&search.pl', 'G/ET-я', 'Яr/esults_frame', 'Яr/e', 'name="search_form" class="search-form"');
    perform htp_formclose();
    perform htp_fontopen('BL/UE', 'Verd/ana', '3/4', 'name="search_form" class="search-form"');
    perform htp_fontclose();
    perform htp_formselectopen('"hobby_list', 'Ва"ши хобби: ', 8.7, 'multiple style="width: 200px;"');
    perform htp_formselectclose();
    perform htp_framesetopen('', '25%, 75%', 'border="1"');
    perform htp_framesetclose();
    perform htp_mapopen(NULL, NULL);
    perform htp_mapclose();
    perform htp_olistopen('both"', 'soft"', NULL);
    perform htp_olistclose();
    perform htp_preopen('both"', '80"', 'class="source-code" style="font-size:12px;"');
    perform htp_preclose();
    perform htp_tableopen(' ', ' ', ' ', ' ', ' ');
    perform htp_tableclose();
    perform htp_tablerowopen('CENTER"', 'MIDDLE"', '1"', 'yes"', 'style="background-color: #E0E0E0;"');
    perform htp_tablerowclose();
    perform htp_ulistopen('a"', 'HORIZ"', '⚡', 'd"', 'class="energy-list" id="main"');
    perform htp_ulistclose();
    perform htp_centeropen();
    perform htp_centerclose();
    perform htp_dirlistopen();
    perform htp_dirlistclose();
    perform htp_headopen();
    perform htp_headclose();
    perform htp_htmlopen();
    perform htp_htmlclose();
    perform htp_listingopen();
    perform htp_listingclose();
    perform htp_menulistopen();
    perform htp_menulistclose();
    perform htp_noframesopen();
    perform htp_noframesclose();
    perform htp_escape_sc('Россия qwerasdf1234" & . @ '' ');
    perform htp_escape_sc('Visit <our site> & enjoy! !@#$%^&*()_+|/');
    perform htp_formcheckbox('"interests', '"travel', '9', 'style="color: blue;"');
    perform htp_formfile('"interests', '"travel', 'style="color: blue;"');
    perform htp_formhidden('"i', '"t', 'style="c"');
    perform htp_formimage('"i', '"t', '"','style="c"');
    perform htp_formpassword('"i', '"t', '"','"w"', 'style="c"');
    perform htp_formradio('"i', '"t', '"', 'style="c"');
    perform htp_formreset('"i', 'style="c"');
    perform htp_formselectoption('"i', '"','style="c"');
    perform htp_formsubmit('"i', '"','style="c"');
    perform htp_formtext('"i', '"','"9"', '"2"', 'style="c"');
    perform htp_formtextarea('"i', 2, 9, '"2"', 'style="c"');
    perform htp_formtextarea2('"i', 2.9, 9, '"2"', ' ', 'style="c"');
    perform htp_address(NULL, '', 'Б"al l*', 'style="font-style: italic;"');
    perform htp_anchor(NULL, 'NEW* сайт', 'x"в', 'class="external"');
    perform htp_area('x"в','x"в','x"в','x"в','x"в', 'b"Я');
    perform htp_get_data();
END $$;
 
-- htp_em tests
DO $$
BEGIN
    perform htp_em('NICE');
    perform htp_em('найс'); -- converts russian symbols in html unicode codes
    perform htp_em('🙂'); -- emoji is converted to html unicode too
    perform htp_em('<script>alert(1)</script>');
    perform htp_em('Test ''Single Quotes''');
    perform htp_em('A < B > C & D');
    perform htp_em('Tab s Here');   
    perform htp_em('Line
Break');
    perform htp_em('');              -- Empty string
    perform htp_em(NULL);            -- NULL value
    perform htp_em(' ');             -- Single space
    perform htp_em('Emphasized', 'class="highlight"');
    perform htp_em('Text', 'style="font-weight: bold;"');
    perform htp_em('Link', 'id="my-id"');
    perform htp_em('Mixed', 'class="test" id="x" style="color:red"');
    perform htp_em('<script>', 'onclick="alert(1)"');
    perform htp_em('Text', 'data-value="<script>"');
    perform htp_em('Emphasized');
    perform htp_em(NULL, 'class="test"');
    perform htp_em('Text', NULL);
    perform htp_em('Text', '');
    perform htp_em(NULL, NULL);
    perform htp_get_data();
END $$;
 
-- htp_frame tests
DO $$
BEGIN
    perform htp_frame('https://awww.ru');
    perform htp_frame('найс'); -- outputs unicode
    perform htp_frame('<script>alert(1)</script>');
    perform htp_frame('A < B > C & D');
    perform htp_frame('Line
Break');
    perform htp_frame(''); -- Empty string
    perform htp_frame(NULL); -- NULL value
    perform htp_frame(' ');
    perform htp_frame('Col1 Col2    Col3'); -- Tab handling
    perform htp_frame(chr(9) || 'Test' || chr(9));
    perform htp_frame('https://awww.ru', 'art site', '100', '100', 'yes', '555', 'index_rate=100'); -- name escapes space!
    perform htp_frame('https://awww.ru', 'space_test', '1 00', '10 0', 'ye s', '555', 'index_rate=10 0'); -- all attrs are escaping space but not cattr
    perform htp_frame('https://awww.ru', '555', 'abc', 'zyx', '444', 'canresize', 'index_rate=100'); -- attrs are messed up logically
    perform htp_frame('https://awww.ru', 'абв', 'где', 'ёжз', 'ийк', 'лмн', 'index_rate=опр'); -- attrs are escaping unicode, noresize is ok, cattrs is not escaped
    perform htp_frame('https://awww.ru', 'symbols_linebreaks_test', 'F < G > H & I', 
    'J < K > 
    L & M', 'E < O > P & N', 
    'Q < R > S & T', 'U < V > W & X');
    perform htp_frame('https://spaces.nul0', '', '', '', '', '', '');
    perform htp_frame('https://spaces.nul1', ' ', ' ', ' ', ' ', ' ', ' ');
    perform htp_frame('https://symbols.esc', '\n', '\r', '\t', '\\', '\n', '\n'); -- '\' is escaped as html unicode for attrs
    perform htp_get_data();
END $$;
 
-- htp_header tests
DO $$
BEGIN
    perform htp_header(NULL, 'Invalid tag');
    perform htp_header(1, 'Pretty Normal');
    perform htp_header(7, 'Tag overflow'); -- 7 is converted to 6
    perform htp_header(0, 'Invalid 0 tag'); -- 0 is okay
    perform htp_header(13, 'найс'); -- converts russian symbols in html unicode codes
    perform htp_header(-2, '🙂'); -- emoji is converted to html unicode too, -2 is 2
    perform htp_header(-12, '🙂'); -- emoji is converted to html unicode too, -12 is 6
    perform htp_header(1, '<script>alert(1)</script>');
    perform htp_header(1, 'A < B > C & D');
    perform htp_header(1, 'Line
Break');
    perform htp_header(1, '');              -- Empty string
    perform htp_header(1, NULL);            -- NULL value
    perform htp_header(1, ' ');             -- Single space
    perform htp_header(1, 'A < B > C & D', 'A < B > C & D', 'A < B > C & D', 'A < B > C & D', 'A < B > C & D');
    perform htp_header(2, '', '', '', '', '');
    perform htp_get_data();
END $$;
 
-- OWA_UTIL.SHOWPAGE extended call form with HTP output
DO $$
BEGIN
    RAISE NOTICE 'Expected:';
    RAISE NOTICE 'HTP_SHOWPAGE_UTILS_BODY';
    RAISE NOTICE 'Actual:';
    PERFORM owa_init_cgi_env(0, NULL, NULL);
    PERFORM htp_p('HTP_SHOWPAGE_UTILS_BODY'::varchar2);
    PERFORM owa_util_showpage_utils(0::int4);
END $$;
 
-- htp_dlistterm tests
DO $$
BEGIN
    perform htp_dlistterm();
    perform htp_dlistterm('anna');
    perform htp_dlistterm(NULL);
    perform htp_dlistterm('');
    perform htp_dlistterm('найс'); -- converts russian symbols in html unicode codes
    perform htp_dlistterm('🙂'); -- emoji is converted to html unicode too
    perform htp_dlistterm('<script>alert(1)</script>');
    perform htp_dlistterm('A < B > C & D'); -- converts special symbols to html unicode
    perform htp_dlistterm('Line
Break');
    perform htp_dlistterm('some term', 'not clear', 'index_rate=100'); -- cclear escapes space
    perform htp_dlistterm('ийк', 'лмн', 'index_rate=опр');
    perform htp_dlistterm('E < O > P & N', 'Q < R > S & T', 'U < V > W & X');
    perform htp_dlistterm('', '', '');
    perform htp_dlistterm(' ', ' ', ' '); -- cclear escapes space
    perform htp_dlistterm('\n', '\r', '\t'); -- cclear escapes slash
    perform htp_dlistterm(chr(9) || 'Test' || chr(9), 'Col1 Col2    Col3', chr(9) || 'Test' || chr(9)); -- cclear escapes tabs
    perform htp_dlistterm(chr(1) || chr(2) || chr(3), chr(27), chr(8));
    perform htp_get_data();
END $$;
 
-- htp_adddefaulthtmlhdr tests
DO $$
BEGIN
    perform htp_adddefaulthtmlhdr(TRUE);
    perform htp_em('hello world');
    perform htp_dlistterm('заголовок');
    perform htp_get_data();
    perform htp_adddefaulthtmlhdr(FALSE);
END $$;
 
-- htp_base tests
DO $$
BEGIN
    perform htp_base('Normal', 'usage=1');
    perform htp_base(); -- empty
    perform htp_base(NULL);
    perform htp_base('');
    perform htp_base('найс'); -- converts russian symbols in html unicode codes
    perform htp_base('🙂'); -- emoji is converted to html unicode too
    perform htp_base('A < B > C & D'); -- converts special symbols to html unicode
    perform htp_base('Line
Break');
    perform htp_base('some term', 'index_rate=100'); -- target attr escapes space
    perform htp_base('ийк', 'index_rate=опр');
    perform htp_base('E < O > P & N', 'U < V > W & X');
    perform htp_base('', '');
    perform htp_base(' ', ' '); -- all used, target attr escapes space
    perform htp_base('\n', '\t'); -- target attr escapes slash
    perform htp_base(chr(9) || 'Test' || chr(9), 'Col1  Col2    Col3'); -- target attr escapes tabs
    perform htp_base(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_basefont tests
DO $$
BEGIN
    perform htp_basefont(-100);
    perform htp_basefont(0);
    perform htp_basefont(100);
    perform htp_basefont(1000);
    perform htp_basefont(1000000);
    perform htp_basefont(999999999999);
    perform htp_get_data();
END $$;
 
--htp_bgsound tests
DO $$
BEGIN
    perform htp_bgsound('Normal', 'tag', 'usage=1');
    perform htp_bgsound(NULL);
    perform htp_bgsound('');
    perform htp_bgsound('найс'); -- converts russian symbols in html unicode codes
    perform htp_bgsound('🙂'); -- emoji is converted to html unicode too
    perform htp_bgsound('A < B > C & D', 'A < B > C & D'); -- converts special symbols to html unicode
    perform htp_bgsound('Line
Break', 'Line
Break');
    perform htp_bgsound('some term', 'some term', 'index_rate=100'); -- escapes space
    perform htp_bgsound('ийк', 'абв', 'index_rate=опр');
    perform htp_bgsound('E < O > P & N', 'U < V > W & X');
    perform htp_bgsound('', '');
    perform htp_bgsound(' ', ' '); -- src and loop escape space
    perform htp_bgsound('\n', '\t'); -- src and loop escape slash
    perform htp_bgsound(chr(9) || 'Test' || chr(9), 'Col1   Col2    Col3'); -- src and loop escape tabs
    perform htp_bgsound(chr(1) || chr(2) || chr(3), chr(27) || chr(2) || chr(3));
    perform htp_get_data();
END $$;
 
--htp_big tests
DO $$
BEGIN
    perform htp_big('Normal', 'usage=1');
    perform htp_big(NULL);
    perform htp_big('');
    perform htp_big('найс'); -- converts russian symbols in html unicode codes
    perform htp_big('🙂'); -- emoji is converted to html unicode too
    perform htp_big('A < B > C & D'); -- converts special symbols to special html code
    perform htp_big('Line
Break'); -- doesn't convert linebreak
    perform htp_big('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_big('ийк', 'index_rate=опр');
    perform htp_big('E < O > P & N', 'U < V > W & X');
    perform htp_big('', '');
    perform htp_big(' ', ' ');
    perform htp_big('\n', '\t'); -- doesn't escape slash
    perform htp_big(chr(9) || 'Test' || chr(9), 'Col1   Col2    Col3'); -- doesn't escape tabs
    perform htp_big(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_bold tests
DO $$
BEGIN
    perform htp_bold('Normal', 'usage=1');
    perform htp_bold(NULL);
    perform htp_bold('');
    perform htp_bold('здесь'); -- converts russian symbols in html unicode codes
    perform htp_bold('🙂'); -- emoji is converted to html unicode too
    perform htp_bold('A < B > C & D'); -- converts special symbols to special html code
    perform htp_bold('Line
Break'); -- doesn't convert linebreak
    perform htp_bold('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_bold('ийк', 'index_rate=опр');
    perform htp_bold('E < O > P & N', 'U < V > W & X');
    perform htp_bold('', '');
    perform htp_bold(' ', ' ');
    perform htp_bold('\n', '\t'); -- doesn't escape slash
    perform htp_bold(chr(9) || 'Test' || chr(9), 'Col1  Col2    Col3'); -- doesn't escape tabs
    perform htp_bold(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_br tests
DO $$
BEGIN
    perform htp_br('Normal', 'usage=1');
    perform htp_br(); -- empty
    perform htp_br(NULL);
    perform htp_br('');
    perform htp_br('камень'); -- converts russian symbols in html unicode codes
    perform htp_br('🙂'); -- emoji is converted to html unicode too
    perform htp_br('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_br('Line
Break'); -- converts linebreak to html unicode codes
    perform htp_br('some term', 'index_rate=100'); -- escapes space
    perform htp_br('ийк', 'index_rate=опр');
    perform htp_br('E < O > P & N', 'U < V > W & X');
    perform htp_br('', '');
    perform htp_br(' ', ' ');
    perform htp_br('\n', '\t'); -- escapes slash
    perform htp_br(chr(9) || 'Test' || chr(9), 'Col1    Col2    Col3'); -- escapes tabs
    perform htp_br(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_center tests
DO $$
BEGIN
    perform htp_center('Normal usage');
    perform htp_center(NULL);
    perform htp_center('');
    perform htp_center('лёд'); -- converts russian symbols in html unicode codes
    perform htp_center('🙂'); -- emoji is converted to html unicode too
    perform htp_center('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_center('Line
Break'); -- doesn't escape linebreak
    perform htp_center('\n\t'); -- doesn't escape slash
    perform htp_center(chr(9) || 'Test' || chr(9)); -- doesn't escape tabs
    perform htp_center(chr(1) || chr(2) || chr(3));
    perform htp_get_data();
END $$;
 
--htp_cite tests
DO $$
BEGIN
    perform htp_cite('Normal', 'usage=1');
    perform htp_cite(NULL);
    perform htp_cite('');
    perform htp_cite('ножницы'); -- converts russian symbols in html unicode codes
    perform htp_cite('🙂'); -- emoji is converted to html unicode too
    perform htp_cite('A < B > C & D'); -- converts special symbols to special html code
    perform htp_cite('Line
Break'); -- doesn't convert linebreak
    perform htp_cite('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_cite('ийк', 'index_rate=опр');
    perform htp_cite('E < O > P & N', 'U < V > W & X');
    perform htp_cite('', '');
    perform htp_cite(' ', ' ');
    perform htp_cite('\n', '\t'); -- doesn't escape slash
    perform htp_cite(chr(9) || 'Test' || chr(9), 'Col1  Col2    Col3'); -- doesn't escape tabs
    perform htp_cite(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_code tests
DO $$
BEGIN
    perform htp_code('Normal', 'usage=1');
    perform htp_code(NULL);
    perform htp_code('');
    perform htp_code('бумага'); -- converts russian symbols in html unicode codes
    perform htp_code('🙂'); -- emoji is converted to html unicode too
    perform htp_code('A < B > C & D'); -- converts special symbols to special html code
    perform htp_code('Line
Break'); -- doesn't convert linebreak
    perform htp_code('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_code('ийк', 'index_rate=опр');
    perform htp_code('E < O > P & N', 'U < V > W & X');
    perform htp_code('', '');
    perform htp_code(' ', ' ');
    perform htp_code('\n', '\t'); -- doesn't escape slash
    perform htp_code(chr(9) || 'Test' || chr(9), 'Col1  Col2    Col3'); -- doesn't escape tabs
    perform htp_code(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_comment tests
DO $$
BEGIN
    perform htp_comment('Normal usage');
    perform htp_comment(NULL);
    perform htp_comment('');
    perform htp_comment('ящерица'); -- converts russian symbols in html unicode codes
    perform htp_comment('🙂'); -- emoji is converted to html unicode too
    perform htp_comment('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_comment('Line
Break'); -- doesn't convert linebreak
    perform htp_comment(' ');
    perform htp_comment('\n\t'); -- doesn't escape slash
    perform htp_comment(chr(9) || 'Test' || chr(9)); -- doesn't escape tabs
    perform htp_comment(chr(1) || chr(2) || chr(3));
    perform htp_get_data();
END $$;
 
--htp_dfn tests
DO $$
BEGIN
    perform htp_dfn('Normal usage');
    perform htp_dfn('Normal usage', 'attr=100');
    perform htp_dfn(NULL);
    perform htp_dfn('');
    perform htp_dfn('колодец'); -- converts russian symbols in html unicode codes
    perform htp_dfn('🙂'); -- emoji is converted to html unicode too
    perform htp_dfn('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_dfn('Line
Break'); -- doesn't convert linebreak
    perform htp_dfn('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_dfn('E < O > P & N', 'U < V > W & X');
    perform htp_dfn('', '');
    perform htp_dfn(' ');
    perform htp_dfn('\n\t'); -- doesn't escape slash
    perform htp_dfn(chr(9) || 'Test' || chr(9)); -- doesn't escape tabs
    perform htp_dfn(chr(1) || chr(2) || chr(3));
    perform htp_get_data();
END $$;
 
--htp_div tests
DO $$
BEGIN
    perform htp_div('Normal', 'usage=1');
    perform htp_div();
    perform htp_div(NULL);
    perform htp_div(NULL, NULL);
    perform htp_div('');
    perform htp_div('пламя'); -- converts russian symbols in html unicode codes
    perform htp_div('🙂'); -- emoji is converted to html unicode too
    perform htp_div('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_div('Line
Break'); -- converts linebreak
    perform htp_div('some term', 'index_rate=100'); -- escapes space
    perform htp_div('ийк', 'index_rate=опр');
    perform htp_div('E < O > P & N', 'U < V > W & X');
    perform htp_div('', '');
    perform htp_div(' ', ' ');
    perform htp_div('\n', '\t'); -- escapes slash
    perform htp_div(chr(9) || 'Test' || chr(9), 'Col1   Col2    Col3'); -- escapes tabs
    perform htp_div(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_dlistdef tests
DO $$
BEGIN
    perform htp_dlistdef('Normal usage', 'left', 'myValue=66');
    perform htp_dlistdef();
    perform htp_dlistdef(NULL);
    perform htp_dlistdef('');
    perform htp_dlistdef('вода'); -- converts russian symbols in html unicode codes
    perform htp_dlistdef('🙂'); -- emoji is converted to html unicode too
    perform htp_dlistdef('Line
Break'); -- doesn't convert linebreak
    perform htp_dlistdef('some term', 'left right', 'index_rate=100');
    perform htp_dlistdef('ийк', 'абв', 'index_rate=опр');
    perform htp_dlistdef('E < O > P & N', 'U < V > W & X', 'U < V > W & X');
    perform htp_dlistdef('<script>alert(4444)</script>', '<script>alert(55555)</script>', 'index_rate=<script>alert(666666)</script>');
    perform htp_dlistdef('', '', '');
    perform htp_dlistdef(' ', ' ', ' ');
    perform htp_dlistdef('\n', '\r', '\t');
    perform htp_dlistdef(chr(9) || 'Test' || chr(9), chr(9) || 'Test' || chr(9), 'Col1  Col2    Col3');
    perform htp_dlistdef(chr(1) || chr(2) || chr(3), chr(27), chr(8));
    perform htp_get_data();
END $$;
 
--htp_escape_sc tests
DO $$
BEGIN
    perform htp_escape_sc('Normal&usage');
    perform htp_escape_sc(NULL); -- nothing at all
    perform htp_escape_sc(''); -- nothing at all
    perform htp_escape_sc('оборот'); -- does not convert russian symbols in html unicode codes
    perform htp_escape_sc('🙂'); -- does not convert emoji to html unicode too
    perform htp_escape_sc('A < B > C & D "'); -- converts special symbols to html unicode codes
    perform htp_escape_sc('Line
Break'); -- does not convert linebreak to html unicode codes
    perform htp_escape_sc(' ');
    perform htp_escape_sc('\n\t'); -- doesn't escape slash
    perform htp_escape_sc(chr(9) || 'Test' || chr(9)); -- doesn't escape tabs
    perform htp_escape_sc(chr(1) || chr(2) || chr(3));
    perform htp_get_data();
END $$;
 
--htp_hr tests
DO $$
BEGIN
    perform htp_hr('left', '/images/line.jpg', 'myValue=66');
    perform htp_hr();
    perform htp_hr(NULL);
    perform htp_hr('');
    perform htp_hr('🙂', '🙂'); -- emoji is converted to html unicode by cclear but not by csrc
    perform htp_hr('Line
Break'); -- converts linebreak
    perform htp_hr('left right', 'some term', 'index_rate 100'); -- space is converted to html unicode by cclear but not by csrc
    perform htp_hr('ийк', 'абв', 'index_rate=опр'); -- csrc doesn't convert russian symbols to unicode
    perform htp_hr('E < O > P & N', 'U < V > W & X', 'U < V > W & X');
    perform htp_hr('<script>alert(4444)</script>', '<script>alert(55555)</script>', 'index_rate=<script>alert(666666)</script>');
    perform htp_hr('', '', '');
    perform htp_hr(' ', ' ', ' ');
    perform htp_hr('\n', '\r', '\t'); -- slash is converted to html unicode by cclear but not by csrc
    perform htp_hr(chr(9) || 'Test' || chr(9), chr(9) || 'Test' || chr(9), 'Col1    Col2    Col3'); -- tab is converted to html unicode by cclear but not by csrc
    perform htp_hr(chr(1) || chr(2) || chr(3), chr(27), chr(8));
    perform htp_get_data();
END $$;
 
--htp_htitle tests
DO $$
BEGIN
    perform htp_htitle('Normal&usage');
    perform htp_htitle('заголовок');
    perform htp_htitle('🙂');
    perform htp_htitle('<script>alert(1)</script>');
    perform htp_htitle('A < B > C & D');
    perform htp_htitle('Line
Break');
    perform htp_htitle('');
    perform htp_htitle(NULL);
    perform htp_htitle(' ');
    perform htp_htitle('TITLE', 16, 'align', 'nowrap', 'clear', 'index_rate=100');
    perform htp_htitle('TIT LE', -10, 'ali gn', 'no wrap', 'cle ar', 'index_rate 100');
    perform htp_htitle('Заголовок', 14, 'расположение', 'обертка', 'выключка', 'атрибут');
    perform htp_htitle('🔥💻🚀', 5, '🔥💻🚀', '🔥💻🚀', 'index_rate=🔥💻🚀', ' ');
    perform htp_htitle('U < V > W & X', 1, 'F < G > H & I', 'J < K > L & M', 'E < O > P & N', 'Q < R > S & T');
    perform htp_htitle(' ', 0, ' ', ' ', ' ', ' ');
    perform htp_htitle('\n', 1, '\t', '\\', '\n', '\n');
    perform htp_htitle(chr(9) || 'Test' || chr(9), 2, 'Col1 Col2    Col3', chr(9) || 'Test' || chr(9), chr(9) || 'Test' || chr(9), 'Col1    Col2    Col3');
    perform htp_get_data();
END $$;
 
--htp_img tests
DO $$
BEGIN
    perform htp_img('/images/what.jpg', 'left', 'The horse', 'yes', 'index_rate=100'); -- alt escapes space
    perform htp_img('WHAT?');
    perform htp_img('гора'); -- doesn't convert russian symbols in html unicode codes
    perform htp_img('🙂'); -- emoji is not converted to html unicode too
    perform htp_img('<script>alert(1)</script>');
    perform htp_img('A < B > C & D');
    perform htp_img('Line
Break');
    perform htp_img('');              -- Empty string
    perform htp_img(NULL);            -- NULL value
    perform htp_img(' ');             -- Single space
    perform htp_img('/images/ what.jpg', 'le ft', 'The horse', 'ye s', 'index_rate 100'); -- all attrs are escaping space but not cattr and src
    perform htp_img('пикчр', 'левый', 'Лошадь', 'да', 'атрибут 30'); -- src doesn't escape unicode, alt and align do, cattrs is not escaped
    perform htp_img('🔥💻🚀', '🔥💻🚀', '🔥💻🚀', '🔥💻🚀', 'index_rate=🔥💻🚀'); -- same
    perform htp_img('U < V > W & X', 'F < G > H & I', 'J < K > L & M', 'E < O > P & N', 'Q < R > S & T');
    perform htp_img('', '', '', '', '');  
    perform htp_img(' ', ' ', ' ', ' ', ' ');
    perform htp_img('\n', '\t', '\\', '\n', '\n');
    perform htp_img(chr(9) || 'Test' || chr(9), 'Col1   Col2    Col3', 
        chr(9) || 'Test' || chr(9), chr(9) || 'Test' || chr(9), 'Col1   Col2    Col3');
    perform htp_get_data();
END $$;
 
--htp_img2 tests
DO $$
BEGIN
    perform htp_img2('/images/what.jpg', 'left', 'The horse', 'yes', 'map.jpg', 'index_rate=100'); -- alt escapes space
    perform htp_img2('WHAT?');
    perform htp_img2('скала'); -- doesn't convert russian symbols in html unicode codes
    perform htp_img2('🙂'); -- emoji is not converted to html unicode too
    perform htp_img2('<script>alert(1)</script>');
    perform htp_img2('A < B > C & D');
    perform htp_img2('Line
Break');
    perform htp_img2('');              -- Empty string
    perform htp_img2(NULL);            -- NULL value
    perform htp_img2(' ');             -- Single space
    perform htp_img2('/images/ what.jpg', 'le ft', 'The horse', 'ye s', 'map .jpg', 'index_rate 100'); -- all attrs are escaping space but not cattr and src
    perform htp_img2('пикчр', 'левый', 'Лошадь', 'да', 'карта', 'атрибут 30'); -- src doesn't escape unicode, alt and align do, cattrs is not escaped
    perform htp_img2('🔥💻🚀', '🔥💻🚀', '🔥💻🚀', '🔥💻🚀', '🔥💻🚀', 'index_rate=🔥💻🚀'); -- same
    perform htp_img2('U < V > W & X', 'F < G > H & I', 'J < K > L & M', 'E < O > P & N', 'Q < R > S & T', 'U < V > X & Y');
    perform htp_img2('', '', '', '', '', '');  
    perform htp_img2(' ', ' ', ' ', ' ', ' ', ' ');
    perform htp_img2('\n', '\t', '\\', '\n', '\n', '\t');
    perform htp_img2(chr(9) || 'Test' || chr(9), 'Col1  Col2    Col3', 
        chr(9) || 'Test' || chr(9), chr(9) || 'Test' || chr(9), 
        'Col1   Col2    Col3', 'Col1    Col2    Col3');
    perform htp_get_data();
END $$;
 
--htp_isindex tests
DO $$
BEGIN
    perform htp_isindex('Enter the message...', 'https://somesite.ru');
    perform htp_isindex();
    perform htp_isindex(NULL);
    perform htp_isindex('');
    perform htp_isindex('холл'); -- converts russian symbols in html unicode codes
    perform htp_isindex('🙂'); -- emoji is converted to html unicode too
    perform htp_isindex('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_isindex('Line
Break'); -- converts linebreak
    perform htp_isindex('ийк', 'опр');
    perform htp_isindex('E < O > P & N', 'U < V > W & X');
    perform htp_isindex('', '');
    perform htp_isindex(' ', ' '); -- prompt escapes spaces
    perform htp_isindex('\n', '\t'); -- prompt escapes slash
    perform htp_isindex(chr(9) || 'Test' || chr(9), 'Col1   Col2    Col3'); -- prompt escapes tabs
    perform htp_isindex(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_line tests
DO $$
BEGIN
    perform htp_line('left', '/images/line.jpg', 'myValue=77');
    perform htp_line();
    perform htp_line(NULL);
    perform htp_line('');
    perform htp_line('🙂', '🙂'); -- emoji is converted to html unicode by cclear but not by csrc
    perform htp_line('Line
Break'); -- converts linebreak
    perform htp_line('left right', 'some term', 'index_rate 100'); -- space is converted to html unicode by cclear but not by csrc
    perform htp_line('ийк', 'абв', 'index_rate=опр'); -- csrc doesn't convert russian symbols to unicode
    perform htp_line('E < O > P & N', 'U < V > W & X', 'U < V > W & X');
    perform htp_line('<script>alert(4444)</script>', '<script>alert(55555)</script>', 'index_rate=<script>alert(666666)</script>');
    perform htp_line('', '', '');
    perform htp_line(' ', ' ', ' ');
    perform htp_line('\n', '\r', '\t'); -- slash is converted to html unicode by cclear but not by csrc
    perform htp_line(chr(9) || 'Test' || chr(9), chr(9) || 'Test' || chr(9), 'Col1  Col2    Col3'); -- tab is converted to html unicode by cclear but not by csrc
    perform htp_line(chr(1) || chr(2) || chr(3), chr(27), chr(8));
    perform htp_get_data();
END $$;
 
--htp_italic tests
DO $$
BEGIN
    perform htp_italic('This one should be italic', 'usage=27');
    perform htp_italic(NULL);
    perform htp_italic('');
    perform htp_italic('мебель'); -- converts russian symbols in html unicode codes
    perform htp_italic('🙂'); -- emoji is converted to html unicode too
    perform htp_italic('A < B > C & D'); -- converts special symbols to special html code
    perform htp_italic('Line
Break'); -- doesn't convert linebreak
    perform htp_italic('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_italic('ийк', 'index_rate=опр');
    perform htp_italic('E < O > P & N', 'U < V > W & X');
    perform htp_italic('', '');
    perform htp_italic(' ', ' ');
    perform htp_italic('\n', '\t'); -- doesn't escape slash
    perform htp_italic(chr(9) || 'Test' || chr(9), 'Col1    Col2    Col3'); -- doesn't escape tabs
    perform htp_italic(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_kbd tests
DO $$
BEGIN
    perform htp_kbd('This one should be monospace', 'usage=66');
    perform htp_kbd(NULL);
    perform htp_kbd('');
    perform htp_kbd('зарево'); -- converts russian symbols in html unicode codes
    perform htp_kbd('🙂'); -- emoji is converted to html unicode too
    perform htp_kbd('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_kbd('Line
Break'); -- doesn't convert linebreak
    perform htp_kbd('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_kbd('ийк', 'index_rate=опр');
    perform htp_kbd('E < O > P & N', 'U < V > W & X');
    perform htp_kbd('', '');
    perform htp_kbd(' ', ' ');
    perform htp_kbd('\n', '\t'); -- doesn't escape slash
    perform htp_kbd(chr(9) || 'Test' || chr(9), 'Col1   Col2    Col3'); -- doesn't escape tabs
    perform htp_kbd(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_keyboard tests
DO $$
BEGIN
    perform htp_keyboard('This one should be monospace too', 'usage=70');
    perform htp_keyboard(NULL);
    perform htp_keyboard('');
    perform htp_keyboard('корона'); -- converts russian symbols in html unicode codes
    perform htp_keyboard('🙂'); -- emoji is converted to html unicode too
    perform htp_keyboard('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_keyboard('Line
Break'); -- doesn't convert linebreak
    perform htp_keyboard('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_keyboard('ийк', 'index_rate=опр');
    perform htp_keyboard('E < O > P & N', 'U < V > W & X');
    perform htp_keyboard('', '');
    perform htp_keyboard(' ', ' ');
    perform htp_keyboard('\n', '\t'); -- doesn't escape slash
    perform htp_keyboard(chr(9) || 'Test' || chr(9), 'Col1  Col2    Col3'); -- doesn't escape tabs
    perform htp_keyboard(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_linkrel tests
DO $$
BEGIN
    perform htp_linkrel('stylesheet', '/styles/main.css');
    perform htp_linkrel('style sheet', '/styles/ main.css', 'cascade styles'); -- all attrs are escaping space but not href
    perform htp_linkrel('стили', 'главный.ксс', 'таблицы стилей'); -- all attrs are escaping unicode but not href
    perform htp_linkrel('🔥💻🚀', '🔥💻🚀', '🔥💻🚀'); -- same
    perform htp_linkrel('<script>alert(22)</script>', '<script>alert(333)</script>', '<script>alert(4444)</script>'); -- href converts special symbols to html codes, others do a html unicode conv
    perform htp_linkrel('F < G > H & I', 'J < K > L & M', 'E < O > P & N'); 
    perform htp_linkrel('F < G > 
H & I', 'J < K > 
L & M', 'E < O 
> P & N'); -- all attrs are escaping line breaks but not href
    perform htp_linkrel('', '', '');
    perform htp_linkrel(' ', ' ', ' ');
    perform htp_linkrel('\\', '\n', '\t'); -- all attrs are escaping slashes but not href
    perform htp_linkrel('\0', '\xFF', '\x41');
    perform htp_linkrel(NULL, NULL, NULL);
    perform htp_linkrel('Col1   Col2    Col3', 'Col1    Col2    Col3', chr(9) || 'Test' || chr(9)); -- all attrs are escaping tabs but not href
    perform htp_linkrel(chr(1) || chr(2) || chr(3), chr(27), chr(8)); -- all attrs are escaping control chars but not href
    perform htp_get_data();
END $$;
 
--htp_linkrev tests
DO $$
BEGIN
    perform htp_linkrev('htmlpage', '/styles/main.css');
    perform htp_linkrev('style sheet', '/styles/ main.css', 'cascade styles'); -- all attrs are escaping space but not href
    perform htp_linkrev('стили', 'главный.ксс', 'таблицы стилей'); -- all attrs are escaping unicode but not href
    perform htp_linkrev('🔥💻🚀', '🔥💻🚀', '🔥💻🚀'); -- same
    perform htp_linkrev('<script>alert(22)</script>', '<script>alert(333)</script>', '<script>alert(4444)</script>'); -- href converts special symbols to html codes, others do a html unicode conv
    perform htp_linkrev('F < G > H & I', 'J < K > L & M', 'E < O > P & N'); 
    perform htp_linkrev('F < G > 
H & I', 'J < K > 
L & M', 'E < O 
> P & N'); -- all attrs are escaping line breaks but not href
    perform htp_linkrev('', '', '');
    perform htp_linkrev(' ', ' ', ' ');
    perform htp_linkrev('\\', '\n', '\t'); -- all attrs are escaping slashes but not href
    perform htp_linkrev('\0', '\xFF', '\x41');
    perform htp_linkrev(NULL, NULL, NULL);
    perform htp_linkrev('Col1   Col2    Col3', 'Col1    Col2    Col3', chr(9) || 'Test' || chr(9)); -- all attrs are escaping tabs but not href
    perform htp_linkrev(chr(1) || chr(2) || chr(3), chr(27), chr(8)); -- all attrs are escaping control chars but not href
    perform htp_get_data();
END $$;
 
--htp_listheader tests
DO $$
BEGIN
    perform htp_listheader(NULL);
    perform htp_listheader('');
    perform htp_listheader('дворец'); -- converts russian symbols in html unicode codes
    perform htp_listheader('🙂'); -- emoji is converted to html unicode too
    perform htp_listheader('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_listheader('Line
Break'); -- doesn't convert linebreak
    perform htp_listheader('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_listheader('ийк', 'index_rate=опр');
    perform htp_listheader('E < O > P & N', 'U < V > W & X');
    perform htp_listheader('', '');
    perform htp_listheader(' ', ' ');
    perform htp_listheader('\n', '\t'); -- doesn't escape slash
    perform htp_listheader(chr(9) || 'Test' || chr(9), 'Col1    Col2    Col3'); -- doesn't escape tabs
    perform htp_listheader(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_listitem tests
DO $$
BEGIN
    perform htp_listitem();
    perform htp_listitem('');              -- Empty string
    perform htp_listitem(NULL);            -- NULL value
    perform htp_listitem(' ');             -- Single space
    perform htp_listitem('list point', 'lef t', '* *', '/something. html', 'index_rate=10 0'); -- only text and cattr don't escape space
    perform htp_listitem('абв', 'где', 'ёжз', 'ийк', 'лмн'); -- text escapes russian symbols
    perform htp_listitem('🔥💻🚀', '🔥💻🚀', '🔥💻🚀', '🔥💻🚀', 'index_rate=🔥💻🚀'); -- same
    perform htp_listitem('<script>alert(22)</script>', '<script>alert(333)</script>',
             '<script>alert(4444)</script>', '<script>alert(55555)</script>',
             'index_rate=<script>alert(666666)</script>');
    perform htp_listitem('F < G > H & I', 'J < K > L & M', 'E < O > P & N', 
             'Q < R > S & T', 'U < V > W & X'); -- text escapes special symbols to special html code
    perform htp_listitem('F < G > 
H & I', 'J < K > 
L & M', 'E < O 
> P & N', 'Q 
< R > S & T', 'U < V > W 
& X'); -- line break is not escaped in text, cattrs
    perform htp_listitem('', '', '', '', ''); -- '' as null for margins, ' ' as null for noresize
    perform htp_listitem(' ', ' ', ' ', ' ', ' '); -- space is not escaped by text, cattr
    perform htp_listitem('\n', '\r', '\t', '\\', '\n');
    perform htp_listitem('\"', '\x41', '\101', '\0', '\xFF');
    perform htp_listitem('Col1  Col2    Col3', 'Col1    Col2    Col3', 
             chr(9) || 'Test' || chr(9), chr(9) || 'Test' || chr(9), 
             'Col1  Col2    Col3'); -- tab is not escaped by text, cattr
    perform htp_listitem(chr(1) || chr(2) || chr(3), chr(27), chr(8), chr(7), chr(8));
    perform htp_get_data();
END $$;
 
--htp_mailto tests
DO $$
BEGIN
    perform htp_mailto('some@where.net', 'Send email to someone');
    perform htp_mailto('some @where.net', 'Send email to someone', 'Some one', 'index_rate=10 0'); -- only name escapes space
    perform htp_mailto('абв', 'где', 'ёжз', 'ийк'); -- name and text escapes russian symbols
    perform htp_mailto('🔥💻🚀', '🔥💻🚀', '🔥💻🚀', 'index_rate=🔥💻🚀'); -- same
    perform htp_mailto('<script>alert(22)</script>', '<script>alert(333)</script>',
                  '<script>alert(4444)</script>', 'index_rate=<script>alert(666666)</script>');
    perform htp_mailto('F < G > H & I', 'J < K > L & M',
                  'Q < R > S & T', 'U < V > W & X'); -- caddress, ctext, cattr escapes spec symbols to html codes, cname escapes to unicode
    perform htp_mailto('F < G > 
H & I', 'J < K > 
L & M', 'E < O 
> P & N', 'Q 
< R > S & T'); -- caddress, ctext, cattr doesn't escape tabs, cname escapes to unicode
    perform htp_mailto('', '', '', '');
    perform htp_mailto(' ', ' ', ' ', ' '); -- space is escaped by cname
    perform htp_mailto('\n', '\r', '\t', '\\');
    perform htp_mailto('\"', '\x41', '\101', '\0');
    perform htp_mailto('Col1    Col2    Col3', 'Col1    Col2    Col3', 
                   chr(9) || 'Test' || chr(9), chr(9) || 'Test' || chr(9)); -- tab is escaped by cname
    perform htp_mailto(chr(1) || chr(2) || chr(3), chr(27), chr(8), chr(7));
    perform htp_get_data();
END $$;
 
--htp_mapopen tests
DO $$
BEGIN
    perform htp_mapopen(NULL);
    perform htp_mapopen('');
    perform htp_mapopen('Рыбалка'); -- converts russian symbols in html unicode codes
    perform htp_mapopen('🙂'); -- emoji is converted to html unicode too
    perform htp_mapopen('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_mapopen('Line
Break'); -- doesn't convert linebreak
    perform htp_mapopen('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_mapopen('ийк', 'index_rate=опр');
    perform htp_mapopen('E < O > P & N', 'U < V > W & X');
    perform htp_mapopen('', '');
    perform htp_mapopen(' ', ' ');
    perform htp_mapopen('\n', '\t'); -- doesn't escape slash
    perform htp_mapopen(chr(9) || 'Test' || chr(9), 'Col1   Col2    Col3'); -- doesn't escape tabs
    perform htp_mapopen(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_meta tests
DO $$
BEGIN
    perform htp_meta('re fresh', 'Test Site', '3; url=https://www.test.org'); -- everything escapes spaces
    perform htp_meta('абв', 'где', 'ёжз'); -- everything escapes russian symbols
    perform htp_meta('🔥💻🚀', '🔥💻🚀', '🔥💻🚀'); -- same
    perform htp_meta('<script>alert(22)</script>', '<script>alert(333)</script>',
         '<script>alert(4444)</script>');
    perform htp_meta('F < G > H & I', 'J < K > L & M', 'E < O > P & N');
    perform htp_meta('F < G > 
H & I', 'J < K > 
L & M', 'E < O 
> P & N');
    perform htp_meta(NULL, NULL, NULL);
    perform htp_meta('', '', '');
    perform htp_meta(' ', ' ', ' ');
    perform htp_meta('\n', '\r', '\t');
    perform htp_meta('\"', '\x41', '\101');
    perform htp_meta('Col1  Col2    Col3', 'Col1    Col2    Col3', 
          chr(9) || 'Test' || chr(9));
    perform htp_meta(chr(1) || chr(2) || chr(3), chr(27), chr(8));
    perform htp_get_data();
END $$;
 
--htp_nextid tests
DO $$
BEGIN
    perform htp_nextid(NULL);
    perform htp_nextid('');
    perform htp_nextid('Колода');
    perform htp_nextid('🙂');
    perform htp_nextid('A < B > C & D');
    perform htp_nextid('Line
Break');
    perform htp_nextid(' ');
    perform htp_nextid('\n\t');
    perform htp_nextid(chr(9) || 'Test' || chr(9));
    perform htp_nextid(chr(1) || chr(2) || chr(3));
    perform htp_get_data();
END $$;
 
--htp_nl tests
DO $$
BEGIN
    perform htp_nl('Normal', 'usage=1');
    perform htp_nl(); -- empty
    perform htp_nl(NULL);
    perform htp_nl('');
    perform htp_nl('дерево'); -- converts russian symbols in html unicode codes
    perform htp_nl('🙂'); -- emoji is converted to html unicode too
    perform htp_nl('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_nl('Line
Break'); -- converts linebreak to html unicode codes
    perform htp_nl('some term', 'index_rate=100'); -- escapes space
    perform htp_nl('ийк', 'index_rate=опр');
    perform htp_nl('E < O > P & N', 'U < V > W & X');
    perform htp_nl('', '');
    perform htp_nl(' ', ' ');
    perform htp_nl('\n', '\t'); -- escapes slash
    perform htp_nl(chr(9) || 'Test' || chr(9), 'Col1    Col2    Col3'); -- escapes tabs
    perform htp_nl(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_nobr tests
DO $$
BEGIN
    perform htp_nobr(NULL);
    perform htp_nobr('');
    perform htp_nobr('крона'); -- convert russian symbols to html unicode codes
    perform htp_nobr('🙂'); -- converts emoji to html unicode too
    perform htp_nobr('A < B > C & D'); -- converts special symbols to html special codes
    perform htp_nobr('Line
Break'); -- does not convert linebreak
    perform htp_nobr(' ');
    perform htp_nobr('\n\t'); -- doesn't escape slash
    perform htp_nobr(chr(9) || 'Test' || chr(9)); -- doesn't escape tabs
    perform htp_nobr(chr(1) || chr(2) || chr(3));
    perform htp_get_data();
END $$;
 
--htp_paragraph tests
DO $$
BEGIN
    perform htp_paragraph();
    perform htp_paragraph('');              -- Empty string
    perform htp_paragraph(NULL);            -- NULL value
    perform htp_paragraph(' ');             -- Single space
    perform htp_paragraph('le ft', 'ye s', 'le ft', 'myAttr= value'); -- calign cclear escape spaces
    perform htp_paragraph('абв', 'где', 'ёжз', 'икл'); -- calign cclear escape russian symbols
    perform htp_paragraph('🔥💻🚀', '🔥💻🚀', '🔥💻🚀', '🔥💻🚀'); -- same
    perform htp_paragraph('<script>alert(22)</script>', '<script>alert(333)</script>',
              '<script>alert(4444)</script>', '<script>alert(55555)</script>');
    perform htp_paragraph('F < G > H & I', 'J < K > L & M', 
              'E < O > P & N', 'Q < R > S & T'); -- calign cclear escape spec symbols
    perform htp_paragraph('F < G > 
H & I', 'J < K > 
L & M', 'E < O 
> P & N', 'Q < R >
 S & T'); -- calign cclear escape linebreaks
    perform htp_paragraph(NULL, NULL, NULL, NULL);
    perform htp_paragraph('', '', '', '');
    perform htp_paragraph(' ', ' ', ' ', ' '); -- space is escaped by calign cclear
    perform htp_paragraph('\n', '\r', '\t', '\\'); -- slash is escaped by calign cclear
    perform htp_paragraph('\"', '\x41', '\101', '\0');
    perform htp_paragraph('Col1 Col2    Col3', 'Col1    Col2    Col3', 
               chr(9) || 'Test' || chr(9), chr(9) || 'Test' || chr(9)); -- tab is escaped by calign cclear
    perform htp_paragraph(chr(1) || chr(2) || chr(3), chr(27), chr(8), chr(3));
    perform htp_get_data();
END $$;
 
--htp_param tests
DO $$
BEGIN
    perform htp_param('F < G > 
H & I', 'J < K > 
L & M'); -- linebreak is escaped
    perform htp_param('some term', 'index rate'); -- space is escaped
    perform htp_param('🔥💻🚀', '🔥💻🚀'); -- emoji is escaped
    perform htp_param('ийк', 'опр'); -- russian symbols are escaped
    perform htp_param('E < O > P & N', 'U < V > W & X'); -- spec symbols are escaped
    perform htp_param('', '');
    perform htp_param(' ', ' ');
    perform htp_param('\n', '\t');
    perform htp_param(chr(9) || 'Test' || chr(9), 'Col1 Col2    Col3');
    perform htp_param(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_plaintext tests
DO $$
BEGIN
    perform htp_plaintext(NULL);
    perform htp_plaintext('');
    perform htp_plaintext('бокал'); -- converts russian symbols in html unicode codes
    perform htp_plaintext('🙂'); -- emoji is converted to html unicode too
    perform htp_plaintext('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_plaintext('Line
Break'); -- doesn't convert linebreak
    perform htp_plaintext('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_plaintext('ийк', 'index_rate=опр');
    perform htp_plaintext('E < O > P & N', 'U < V > W & X');
    perform htp_plaintext('', '');
    perform htp_plaintext(' ', ' ');
    perform htp_plaintext('\n', '\t'); -- doesn't escape slash
    perform htp_plaintext(chr(9) || 'Test' || chr(9), 'Col1 Col2    Col3'); -- doesn't escape tabs
    perform htp_plaintext(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_prints tests
DO $$
BEGIN
    perform htp_prints(NULL); -- nothing at all
    perform htp_prints(''); -- nothing at all
    perform htp_prints('дорога'); -- does not convert russian symbols in html unicode codes
    perform htp_prints('🙂'); -- does not convert emoji to html unicode too
    perform htp_prints('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_prints('Line
Break'); -- does not convert linebreak to html unicode codes
    perform htp_prints(' ');
    perform htp_prints('\n\t'); -- doesn't escape slash
    perform htp_prints(chr(9) || 'Test' || chr(9)); -- doesn't escape tabs
    perform htp_prints(chr(1) || chr(2) || chr(3));
    perform htp_get_data();
END $$;
 
--htp_ps tests
DO $$
BEGIN
    perform htp_ps(NULL); -- nothing at all
    perform htp_ps(''); -- nothing at all
    perform htp_ps('долгая'); -- does not convert russian symbols in html unicode codes
    perform htp_ps('🙂'); -- does not convert emoji to html unicode too
    perform htp_ps('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_ps('Line
Break'); -- does not convert linebreak to html unicode codes
    perform htp_ps(' ');
    perform htp_ps('\n\t'); -- doesn't escape slash
    perform htp_ps(chr(9) || 'Test' || chr(9)); -- doesn't escape tabs
    perform htp_ps(chr(1) || chr(2) || chr(3));
    perform htp_get_data();
END $$;
 
--htp_s tests
DO $$
BEGIN
    perform htp_s(NULL);
    perform htp_s('');
    perform htp_s('пирог'); -- converts russian symbols in html unicode codes
    perform htp_s('🙂'); -- emoji is converted to html unicode too
    perform htp_s('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_s('Line
Break'); -- doesn't convert linebreak
    perform htp_s('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_s('ийк', 'index_rate=опр');
    perform htp_s('E < O > P & N', 'U < V > W & X');
    perform htp_s('', '');
    perform htp_s(' ', ' ');
    perform htp_s('\n', '\t'); -- doesn't escape slash
    perform htp_s(chr(9) || 'Test' || chr(9), 'Col1 Col2    Col3'); -- doesn't escape tabs
    perform htp_s(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_strike tests
DO $$
BEGIN
    perform htp_strike(NULL);
    perform htp_strike('');
    perform htp_strike('облако'); -- converts russian symbols in html unicode codes
    perform htp_strike('🙂'); -- emoji is converted to html unicode too
    perform htp_strike('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_strike('Line
Break'); -- doesn't convert linebreak
    perform htp_strike('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_strike('ийк', 'index_rate=опр');
    perform htp_strike('E < O > P & N', 'U < V > W & X');
    perform htp_strike('', '');
    perform htp_strike(' ', ' ');
    perform htp_strike('\n', '\t'); -- doesn't escape slash
    perform htp_strike(chr(9) || 'Test' || chr(9), 'Col1    Col2    Col3'); -- doesn't escape tabs
    perform htp_strike(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_samp tests
DO $$
BEGIN
    perform htp_sample(NULL);
    perform htp_sample('');
    perform htp_sample('провод'); -- converts russian symbols in html unicode codes
    perform htp_sample('🙂'); -- emoji is converted to html unicode too
    perform htp_sample('A < B > C & D'); -- converts special symbols to special html code
    perform htp_sample('Line
Break'); -- doesn't convert linebreak
    perform htp_sample('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_sample('ийк', 'index_rate=опр');
    perform htp_sample('E < O > P & N', 'U < V > W & X');
    perform htp_sample('', '');
    perform htp_sample(' ', ' ');
    perform htp_sample('\n', '\t'); -- doesn't escape slash
    perform htp_sample(chr(9) || 'Test' || chr(9), 'Col1    Col2    Col3'); -- doesn't escape tabs
    perform htp_sample(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_small tests
DO $$
BEGIN
    perform htp_small(NULL);
    perform htp_small('');
    perform htp_small('шарнир'); -- converts russian symbols in html unicode codes
    perform htp_small('🙂'); -- emoji is converted to html unicode too
    perform htp_small('A < B > C & D'); -- converts special symbols to special html code
    perform htp_small('Line
Break'); -- doesn't convert linebreak
    perform htp_small('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_small('ийк', 'index_rate=опр');
    perform htp_small('E < O > P & N', 'U < V > W & X');
    perform htp_small('', '');
    perform htp_small(' ', ' ');
    perform htp_small('\n', '\t'); -- doesn't escape slash
    perform htp_small(chr(9) || 'Test' || chr(9), 'Col1 Col2    Col3'); -- doesn't escape tabs
    perform htp_small(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_script tests
DO $$
BEGIN
    perform htp_script(NULL);
    perform htp_script('');
    perform htp_script('собор'); -- converts russian symbols in html unicode codes
    perform htp_script('🙂'); -- emoji is converted to html unicode too
    perform htp_script('A < B > C & D'); -- converts special symbols to special html code
    perform htp_script('Line
Break'); -- doesn't convert linebreak
    perform htp_script('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_script('ийк', 'index_rate=опр');
    perform htp_script('E < O > P & N', 'U < V > W & X');
    perform htp_script('', '');
    perform htp_script(' ', ' ');
    perform htp_script('\n', '\t'); -- doesn't escape slash
    perform htp_script(chr(9) || 'Test' || chr(9), 'Col1    Col2    Col3'); -- doesn't escape tabs
    perform htp_script(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_strong tests
DO $$
BEGIN
    perform htp_strong('Normal', 'usage=1');
    perform htp_strong(NULL);
    perform htp_strong('');
    perform htp_strong('кабриолет'); -- converts russian symbols in html unicode codes
    perform htp_strong('🙂'); -- emoji is converted to html unicode too
    perform htp_strong('A < B > C & D'); -- converts special symbols to special html code
    perform htp_strong('Line
Break'); -- doesn't convert linebreak
    perform htp_strong('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_strong('ийк', 'index_rate=опр');
    perform htp_strong('E < O > P & N', 'U < V > W & X');
    perform htp_strong('', '');
    perform htp_strong(' ', ' ');
    perform htp_strong('\n', '\t'); -- doesn't escape slash
    perform htp_strong(chr(9) || 'Test' || chr(9), 'Col1    Col2    Col3'); -- doesn't escape tabs
    perform htp_strong(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_style tests
DO $$
BEGIN
    perform htp_style(NULL); -- nothing at all
    perform htp_style(''); -- nothing at all
    perform htp_style('закат'); -- convert russian symbols to html unicode codes
    perform htp_style('🙂'); -- converts emoji to html unicode too
    perform htp_style('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_style('Line
Break'); -- does not convert linebreak to html unicode codes
    perform htp_style(' ');
    perform htp_style('\n\t'); -- doesn't escape slash
    perform htp_style(chr(9) || 'Test' || chr(9)); -- doesn't escape tabs
    perform htp_style(chr(1) || chr(2) || chr(3));
    perform htp_get_data();
END $$;
 
--htp_sub tests
DO $$
BEGIN
    perform htp_sub('');              -- Empty string
    perform htp_sub(NULL);            -- NULL value
    perform htp_sub(' ');             -- Single space
    perform htp_sub('subscript data');
    perform htp_sub('сапожник'); -- converts russian symbols in html unicode codes
    perform htp_sub('🙂'); -- emoji is converted to html unicode too
    perform htp_sub('yes', 'left', 'myAttr=value');
    perform htp_sub('ye s', 'le ft', 'myAttr= value'); -- calign escapes spaces
    perform htp_sub('абв', 'где', 'ёжз'); -- calign ctext escape russian symbols
    perform htp_sub('🔥💻🚀', '🔥💻🚀', '🔥💻🚀'); -- same
    perform htp_sub('<script>alert(22)</script>', '<script>alert(333)</script>',
                 '<script>alert(4444)</script>');
    perform htp_sub('F < G > H & I', 'J < K > L & M', 'E < O > P & N');
    perform htp_sub('F < G > 
H & I', 'J < K > 
L & M', 'E < O 
> P & N'); -- calign cclear escape linebreaks
    perform htp_sub(NULL, NULL, NULL);
    perform htp_sub('', '', '');
    perform htp_sub(' ', ' ', ' '); -- space is escaped by calign
    perform htp_sub('\n', '\r', '\t'); -- slash is escaped by calign
    perform htp_sub('\"', '\x41', '\101');
    perform htp_sub('Col1   Col2    Col3', 'Col1    Col2    Col3', 
                chr(9) || 'Test' || chr(9)); -- tab is escaped by calign cclear
    perform htp_sub(chr(1) || chr(2) || chr(3), chr(27), chr(8));
    perform htp_get_data();
END $$;
 
--htp_sup tests
DO $$
BEGIN
    perform htp_sup('');              -- Empty string
    perform htp_sup(NULL);            -- NULL value
    perform htp_sup(' ');             -- Single space
    perform htp_sup('subscript data');
    perform htp_sup('краб'); -- converts russian symbols in html unicode codes
    perform htp_sup('🙂'); -- emoji is converted to html unicode too
    perform htp_sup('yes', 'left', 'myAttr=value');
    perform htp_sup('ye s', 'le ft', 'myAttr= value'); -- calign escapes spaces
    perform htp_sup('абв', 'где', 'ёжз'); -- calign ctext escape russian symbols
    perform htp_sup('🔥💻🚀', '🔥💻🚀', '🔥💻🚀'); -- same
    perform htp_sup('<script>alert(22)</script>', '<script>alert(333)</script>',
         '<script>alert(4444)</script>');
    perform htp_sup('F < G > H & I', 'J < K > L & M', 'E < O > P & N');
    perform htp_sup('F < G > 
H & I', 'J < K > 
L & M', 'E < O 
> P & N'); -- calign cclear escape linebreaks
    perform htp_sup(NULL, NULL, NULL);
    perform htp_sup('', '', '');
    perform htp_sup(' ', ' ', ' '); -- space is escaped by calign
    perform htp_sup('\n', '\r', '\t'); -- slash is escaped by calign
    perform htp_sup('\"', '\x41', '\101');
    perform htp_sup('Col1   Col2    Col3', 'Col1    Col2    Col3', 
        chr(9) || 'Test' || chr(9)); -- tab is escaped by calign cclear
    perform htp_sup(chr(1) || chr(2) || chr(3), chr(27), chr(8));
    perform htp_get_data();
END $$;
 
--htp_tablecaption tests
DO $$
BEGIN
    perform htp_tablecaption('');              -- Empty string
    perform htp_tablecaption(NULL);            -- NULL value
    perform htp_tablecaption(' ');             -- Single space
    perform htp_tablecaption('subscript data');
    perform htp_tablecaption('нож'); -- converts russian symbols in html unicode codes
    perform htp_tablecaption('🙂'); -- emoji is converted to html unicode too
    perform htp_tablecaption('yes', 'left', 'myAttr=value');
    perform htp_tablecaption('ye s', 'le ft', 'myAttr= value'); -- calign escapes spaces
    perform htp_tablecaption('абв', 'где', 'ёжз'); -- calign ctext escape russian symbols
    perform htp_tablecaption('🔥💻🚀', '🔥💻🚀', '🔥💻🚀'); -- same
    perform htp_tablecaption('<script>alert(22)</script>', '<script>alert(333)</script>',
                 '<script>alert(4444)</script>');
    perform htp_tablecaption('F < G > H & I', 'J < K > L & M', 'E < O > P & N');
    perform htp_tablecaption('F < G > 
H & I', 'J < K > 
L & M', 'E < O 
> P & N'); -- calign cclear escape linebreaks
    perform htp_tablecaption(NULL, NULL, NULL);
    perform htp_tablecaption('', '', '');
    perform htp_tablecaption(' ', ' ', ' '); -- space is escaped by calign
    perform htp_tablecaption('\n', '\r', '\t'); -- slash is escaped by calign
    perform htp_tablecaption('\"', '\x41', '\101');
    perform htp_tablecaption('Col1  Col2    Col3', 'Col1    Col2    Col3', 
                chr(9) || 'Test' || chr(9)); -- tab is escaped by calign cclear
    perform htp_tablecaption(chr(1) || chr(2) || chr(3), chr(27), chr(8));
    perform htp_get_data();
END $$;
 
--htp_tabledata tests
DO $$
BEGIN
    perform htp_tabledata('cell');
    perform htp_tabledata('');              -- Empty string
    perform htp_tabledata(NULL);            -- NULL value
    perform htp_tabledata(' ');             -- Single space
    perform htp_tabledata('Todd', 'left', 'rrr10', 'yes', '3', '3', 'index_rate=100');
    perform htp_tabledata('To dd', 'le ft', '1 0', 'ye s', ' 3', ' 3', 'index_rate= 100'); -- all attrs are escaping space but not cvalue and cattr
    perform htp_tabledata('абв', 'где', 'ёжз', 'ийк', 'лмн', 'опр', 'сту'); -- attrs are escaping unicode, cattrs is not escaped
    perform htp_tabledata('🔥💻🚀', '🔥💻🚀', '🔥💻🚀', '🔥💻🚀', '🔥💻🚀', '🔥💻🚀', 'index_rate=🔥💻🚀'); -- same
    perform htp_tabledata('<script>alert()</script>', '<script>alert(1)</script>', '<script>alert(22)</script>', 
                   '<script>alert(333)</script>', '<script>alert(4444)</script>', 
                   '<script>alert(55555)</script>', 'index_rate=<script>alert(666666)</script>'); -- cvalue escapes spec symbs to html spec
    perform htp_tabledata('A < B > C & D', 'E < E > E & E', 'F < G > H & I', 
                   'J < K > L & M', 'E < O > P & N', 
                   'Q < R > S & T', 'U < V > W & X');
    perform htp_tabledata('A < B > 
C & D', 'E < E > 
E & E', 'F < G > 
H & I', 'J < K > 
L & M', 'E < O 
> P & N', 'Q 
< R > S & T', 'U < V > W 
& X'); -- line break is escaped by every attr, not escaped in cattrs, cvalue
    perform htp_tabledata('', '', '', '', '', '', '');
    perform htp_tabledata(' ', ' ', ' ', ' ', ' ', ' ', ' '); -- spaces is not escaped only by cattrs, cvalue
    perform htp_tabledata('\\', '\n', '\r', '\t', '\\', '\n', '\n'); -- '\' is not escaped in cattrs, cvalue
    perform htp_tabledata('\101', '\"', '\x41', '\101', '\0', '\xFF', '\xFF');
    perform htp_tabledata('""', '"', NULL, NULL, '""', '"', '"');
    perform htp_tabledata('Col1 Col2    Col3', 'Col1    Col2    Col3', 'Col1    Col2    Col3', 
                    chr(9) || 'Test' || chr(9), chr(9) || 'Test' || chr(9), 
                    'Col1   Col2    Col3', chr(9) || 'Test' || chr(9));
    perform htp_tabledata(chr(1) || chr(2) || chr(3), chr(1) || chr(2) || chr(3), chr(27),
                        chr(8), chr(7), chr(8), chr(7));
    perform htp_get_data();
END $$;
 
--htp_tableheader tests
DO $$
BEGIN
    perform htp_tableheader('cell');
    perform htp_tableheader('');              -- Empty string
    perform htp_tableheader(NULL);            -- NULL value
    perform htp_tableheader(' ');             -- Single space
    perform htp_tableheader('Todd', 'left', 'rrr10', 'yes', '3', '3', 'index_rate=100');
    perform htp_tableheader('To dd', 'le ft', '1 0', 'ye s', ' 3', ' 3', 'index_rate= 100'); -- all attrs are escaping space but not cvalue and cattr
    perform htp_tableheader('абв', 'где', 'ёжз', 'ийк', 'лмн', 'опр', 'сту'); -- attrs are escaping unicode, cattrs is not escaped
    perform htp_tableheader('🔥💻🚀', '🔥💻🚀', '🔥💻🚀', '🔥💻🚀', '🔥💻🚀', '🔥💻🚀', 'index_rate=🔥💻🚀'); -- same
    perform htp_tableheader('<script>alert()</script>', '<script>alert(1)</script>', '<script>alert(22)</script>', 
                       '<script>alert(333)</script>', '<script>alert(4444)</script>', 
                       '<script>alert(55555)</script>', 'index_rate=<script>alert(666666)</script>'); -- cvalue escapes spec symbs to html spec
    perform htp_tableheader('A < B > C & D', 'E < E > E & E', 'F < G > H & I', 
                        'J < K > L & M', 'E < O > P & N', 
                        'Q < R > S & T', 'U < V > W & X');
    perform htp_tableheader('A < B > 
C & D', 'E < E > 
E & E', 'F < G > 
H & I', 'J < K > 
L & M', 'E < O 
> P & N', 'Q 
< R > S & T', 'U < V > W 
& X'); -- line break is escaped by every attr, not escaped in cattrs, cvalue
    perform htp_tableheader('', '', '', '', '', '', '');
    perform htp_tableheader(' ', ' ', ' ', ' ', ' ', ' ', ' '); -- spaces is not escaped only by cattrs, cvalue
    perform htp_tableheader('\\', '\n', '\r', '\t', '\\', '\n', '\n'); -- '\' is not escaped in cattrs, cvalue
    perform htp_tableheader('\101', '\"', '\x41', '\101', '\0', '\xFF', '\xFF');
    perform htp_tableheader('""', '"', NULL, NULL, '""', '"', '"');
    perform htp_tableheader('Col1   Col2    Col3', 'Col1    Col2    Col3', 'Col1    Col2    Col3', 
                        chr(9) || 'Test' || chr(9), chr(9) || 'Test' || chr(9), 
                        'Col1   Col2    Col3', chr(9) || 'Test' || chr(9));
    perform htp_tableheader(chr(1) || chr(2) || chr(3), chr(1) || chr(2) || chr(3), chr(27),
                        chr(8), chr(7), chr(8), chr(7));
    perform htp_get_data();
END $$;
 
-- htp_teletype tests
DO $$
BEGIN
    perform htp_teletype(NULL);
    perform htp_teletype('');
    perform htp_teletype('Зелено'); -- converts russian symbols in html unicode codes
    perform htp_teletype('🙂'); -- emoji is converted to html unicode too
    perform htp_teletype('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_teletype('Line
Break'); -- doesn't convert linebreak
    perform htp_teletype('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_teletype('ийк', 'index_rate=опр');
    perform htp_teletype('E < O > P & N', 'U < V > W & X');
    perform htp_teletype('', '');
    perform htp_teletype(' ', ' ');
    perform htp_teletype('\n', '\t'); -- doesn't escape slash
    perform htp_teletype(chr(9) || 'Test' || chr(9), 'Col1  Col2    Col3'); -- doesn't escape tabs
    perform htp_teletype(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
-- htp_title tests
DO $$
BEGIN
    perform htp_title(NULL); -- nothing at all
    perform htp_title(''); -- nothing at all
    perform htp_title('много'); -- convert russian symbols to html unicode codes
    perform htp_title('🙂'); -- converts emoji to html unicode too
    perform htp_title('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_title('Line
Break'); -- does not convert linebreak to html unicode codes
    perform htp_title(' ');
    perform htp_title('\n\t'); -- doesn't escape slash
    perform htp_title(chr(9) || 'Test' || chr(9)); -- doesn't escape tabs
    perform htp_title(chr(1) || chr(2) || chr(3));
    perform htp_get_data();
END $$;
 
--htp_underline tests
DO $$
BEGIN
    perform htp_underline(NULL);
    perform htp_underline('');
    perform htp_underline('уголь'); -- converts russian symbols in html unicode codes
    perform htp_underline('🙂'); -- emoji is converted to html unicode too
    perform htp_underline('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_underline('Line
Break'); -- doesn't convert linebreak
    perform htp_underline('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_underline('ийк', 'index_rate=опр');
    perform htp_underline('E < O > P & N', 'U < V > W & X');
    perform htp_underline('', '');
    perform htp_underline(' ', ' ');
    perform htp_underline('\n', '\t'); -- doesn't escape slash
    perform htp_underline(chr(9) || 'Test' || chr(9), 'Col1 Col2    Col3'); -- doesn't escape tabs
    perform htp_underline(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--htp_variable tests
DO $$
BEGIN
    perform htp_variable(NULL);
    perform htp_variable('');
    perform htp_variable('руда'); -- converts russian symbols in html unicode codes
    perform htp_variable('🙂'); -- emoji is converted to html unicode too
    perform htp_variable('A < B > C & D'); -- converts special symbols to html unicode codes
    perform htp_variable('Line
Break'); -- doesn't convert linebreak
    perform htp_variable('some term', 'index_rate=100'); -- doesn't escape space
    perform htp_variable('ийк', 'index_rate=опр');
    perform htp_variable('E < O > P & N', 'U < V > W & X');
    perform htp_variable('', '');
    perform htp_variable(' ', ' ');
    perform htp_variable('\n', '\t'); -- doesn't escape slash
    perform htp_variable(chr(9) || 'Test' || chr(9), 'Col1  Col2    Col3'); -- doesn't escape tabs
    perform htp_variable(chr(1) || chr(2) || chr(3), chr(27));
    perform htp_get_data();
END $$;
 
--common test
DO $$
BEGIN
    perform htp_htitle('Test HTML doc', 1, 'left', 'yes', 'left', 'myAttr=1');
    perform htp_title('Big Great Test Page');
    perform htp_style('body {background-color: #f0f0f0;}');
    perform htp_linkrel('stylesheet', 'main.css', 'css');
    perform htp_linkrev('author', 'book.html', 'War And Peace');
    perform htp_meta('refresh', 'Test Site', '3;url=https://www.test.org');
    perform htp_hr('left', '/images/line.jpg', 'myAttr=2');
    perform htp_line('right', '/images/line2.jpg', 'myAttr=2.5');
    perform htp_basefont(14);
    perform htp_bgsound('town.mid', '-1', 'myAttr=value');
    perform htp_div('', 'myAttr=3');
    perform htp_header(1, 'Test Header');
    perform htp_frame('https://example.com', 'sample site', '100', '100', 'yes', '555', 'myAttr=3.5');
    perform htp_base('_self', 'myAttr=3.7');
    perform htp_comment('Obsolete data');
    perform htp_code('print("Hello World")', 'myAttr=4');
    perform htp_cite('Cite this', 'myAttr=5');
    perform htp_center('Needs to be centered');
    perform htp_br('linebreak', 'myAttr=6');
    perform htp_em('This needs to be emphasized', 'myAttr=6.5');
    perform htp_bold('This needs to be bolder', 'myAttr=7');
    perform htp_big('This needs to be bigger', 'myAttr=7.5');
    perform htp_img('/images/horse.jpg', 'left', 'Horse.', 'yes', 'myAttr=8');
    perform htp_img2('/images/jaguar.jpg', 'left', 'Tiger.', 'yes', '/images/lion.jpg', 'myAttr=9');
    perform htp_isindex('Enter the message...', 'https://somesite.ru');
    perform htp_italic('This one should be italic', 'myAttr=10');
    perform htp_kbd('This one should be monospace', 'myAttr=11');
    perform htp_keyboard('This one should be monospace too', 'myAttr=12');
    perform htp_dfn('Also italic', 'myAttr=13');
    perform htp_listheader('Coffee List', 'myAttr=14');
    perform htp_listitem('listpoint', 'left', '*', '/something.html', 'myAttr=15');
    perform htp_mailto('some@where.net', 'Send email to someone', 'Someone', 'myAttr=16');
    perform htp_mapopen('Infographic', 'myAttr=17');
    perform htp_mapclose();
    perform htp_nextid('Prefix');
    perform htp_nl('linebreak', 'myAttr=18');
    perform htp_nobr('Oneliner');
    perform htp_wbr();
    perform htp_paragraph('left', 'yes', 'left', 'myAttr=17');
    perform htp_param('length', '18');
    perform htp_plaintext('Fixed-width text', 'myAttr=18');
    perform htp_prints('Normal&usage');
    perform htp_ps('std::vector<int>');
    perform htp_s('Dead option', 'myAttr=19');
    perform htp_strike('Another dead option', 'myAttr=20');
    perform htp_sample('Another monospace sample', 'myAttr=21');
    perform htp_small('This needs to be smaller', 'myAttr=22');
    perform htp_script('alert("The number is negative")', 'javascript');
    perform htp_strong('Make it bolder', 'myAttr=23');
    perform htp_sub('subscript data', 'left', 'myAttr=24');
    perform htp_sup('superscript data', 'right', 'myAttr=25');
    perform htp_tablecaption('Big Main Table', 'right', 'myAttr=26');
    perform htp_tableheader('Cell header', 'left', '10', 'yes', '3', '3', 'myAttr=27');
    perform htp_tabledata('Cell data', 'left', '10', 'yes', '3', '3', 'myAttr=28');
    perform htp_teletype('Teletype text', 'myAttr=29');
    perform htp_underline('Underlined text', 'myAttr=30');
    perform htp_variable('Variable in italics', 'myAttr=31');
    perform htp_get_data();
END $$;