Commit graph

106 commits

Author SHA1 Message Date
Yorhel
f50da04ba5 Benchmarks: Improve accuracy + re-run with latest versions 2026-01-10 16:42:06 +01:00
Yorhel
8140fefbca FU::Pg: Rename q() and Q() to sql() and SQL()
Because this easily confuses syntax highlighters and some humans with
the q// string syntax. Also for consistency with the 'fu->sql()'
aliases.

The old names are still available as alias.
2025-12-04 14:16:37 +01:00
Yorhel
144d88fc8b Misc doc fixes 2025-12-04 11:19:40 +01:00
Yorhel
715f4a748b Version 1.3 2025-09-04 11:30:24 +02:00
Yorhel
a8ac435f85 Move control character checking to FU::Validate, deprecate FU::Util::utf8_decode()
URI, JSON and formdata decoding no longer checks for control characters,
but FU::Validate now rejects control characters by default. This
decouples semantic validation from format parsing and gives better
control over when control characters are allowed.
2025-08-22 10:03:06 +02:00
Yorhel
2e9a40da69 More strict UTF-8 validation on input 2025-08-22 09:21:06 +02:00
Yorhel
5a863c20c2 Version 1.2 2025-07-06 07:25:37 +02:00
Yorhel
a7868f74bf Pg: Be more strict with boolean bind parameters
Reason for this is that, with FU::SQL, it's possible to accidentally
introduce a bind parameter when a WHERE clause was intended (i.e.
"WHERE $1"). That's pretty bad, but can easily be caught by simply not
accepting *every* possible value as boolean.
2025-06-12 16:45:09 +02:00
Yorhel
5560d9af60 Version 1.1 2025-06-07 09:49:38 +02:00
Yorhel
55baa6c9a6 json_parse(): Disallow control characters in strings by default
Deviating from the standard, but more consistent other FU functions.
2025-06-04 18:48:08 +02:00
Yorhel
2083ab2a6f Pg: Set appropriate quote_identifier for $conn->Q() 2025-05-22 09:53:41 +02:00
Yorhel
81a3d3c608 SQL: Add IDENT() and quote_identifier options
Turns out VNDB has a few places where request data is directly used for
column names in VALUES/SET/WHERE clauses. These are already restricted
to known strings through the use of FU::Validate, but an extra layer of
protection seems warranted here.
2025-05-22 09:22:07 +02:00
Yorhel
31994a4bf6 Doc typos 2025-05-18 09:51:34 +02:00
Yorhel
32c8fc1b89 Version 1.0 + remove "experimental" notices 2025-05-11 11:03:32 +02:00
Yorhel
383ed8409c bench: version updates + add small Pg benchmark 2025-05-11 10:39:08 +02:00
Yorhel
6c54ee3091 FU: Reject some invalid characters in path 2025-05-09 08:32:41 +02:00
Yorhel
6787f32fd9 DebugInfo: Fix handling of undef and falsy bind parameters 2025-05-03 12:32:52 +02:00
Yorhel
cbccf045b7 DebugInfo: Expand queries table with params & details
Apart from the ugly implementation, this is pretty neat.
2025-05-01 12:18:26 +02:00
Yorhel
76f55f277b Pg: Add text2bin() and bin2text() conversion methods 2025-04-30 20:02:20 +02:00
Yorhel
beeefcf337 Pg: Add perl2bin() and bin2perl() conversion methods 2025-04-30 17:07:44 +02:00
Yorhel
af9340f908 DebugInfo: Styling + add request/response body and fu obj contents
Formatting is still shit.
2025-04-30 15:00:26 +02:00
Yorhel
f8b0043e22 MultipartFormData: Bunch of parser fixes 2025-04-29 09:14:44 +02:00
Yorhel
753cac615a Validate: Improved + extendable error message formatting
Very much needed for VNDB's advanced search validation.
Also completely undocumented.
2025-04-26 15:56:12 +02:00
Yorhel
5f8809d052 FU::Util::query_decode(): Properly handle empty "&"-parts 2025-04-25 17:07:56 +02:00
Yorhel
e88ad65232 Version 0.5 2025-04-24 14:16:17 +02:00
Yorhel
13271fa413 Minor changes & fixes 2025-04-23 16:12:39 +02:00
Yorhel
8096de7497 MultipartFormData: Fix ->save() on zero-length values 2025-04-22 18:54:04 +02:00
Yorhel
1594006739 FU: Improve merging of "Vary" response headers + debug header listing 2025-04-20 11:40:27 +02:00
Yorhel
8b807e6dcf Validate: Add empty() and coerce() methods
Implementing the undocumented coerce_for_json() method from TUWF and
elm_empty() from VNDB.
2025-04-19 12:36:28 +02:00
Yorhel
196b1cc3ce FU: Use CLOCK_MONOTONIC for timing 2025-04-07 16:41:29 +02:00
Yorhel
b3281924d1 Pg: Add escape_literal() and escape_identifier()
Didn't expect I'd ever need these, but they're useful for generating SQL
scripts.
2025-04-07 13:45:33 +02:00
Yorhel
13661b46f9 Validate: Normalize num/int/uint to Perl numeric types + add 64bit limit to int/uint
Normalization may be undone by later validations, but this should work
in most cases.
2025-03-30 13:55:23 +02:00
Yorhel
2f50736782 fdpass_recv: Set O_CLOEXEC on received fds
Turns out this is necessary even if the fd is going to be passed through
exec() soon, because the supervisor might receive multiple fds before
spawning another process, in which case all of them are going to be
passed to the new process instead of just one.
2025-03-24 11:07:39 +01:00
Yorhel
90881924d4 Doc fixes 2025-03-21 11:31:20 +01:00
Yorhel
7c765f33bb Version 0.4 2025-03-19 10:54:23 +01:00
Yorhel
6159b33950 FU::Util: Add brotli_compress() and use it for FU output compression
Seems to compresses and perform better than libdeflate at level 6, so
certainly worth using.
2025-03-19 10:12:20 +01:00
Yorhel
bc33fe53f0 FU::Util: Add gzip_compress() wrapper for libdeflate/zlib-ng/zlib
And use it for automatic output compression in FU, as (potentially)
faster alternative to Compress::Raw::Zlib.

Was also planning to maybe add support for Zstd or Brotli, but given the
performance of libdeflate, I'm not sure that's really necessary. Brotli
does tend to do a better job at compressing HTML, though.
2025-03-18 16:59:43 +01:00
Yorhel
d8ecc71abb FU: Add fu->set_cookie() (+ uri_unescape '+' fix) 2025-03-17 13:46:14 +01:00
Yorhel
a7bfe146b1 Validate: Fix referencing & merging already compiled schemas 2025-03-17 12:50:24 +01:00
Yorhel
3382deba9a Validate: Rename "scalar" to "accept_scalar" and add "accept_array" 2025-03-16 15:39:10 +01:00
Yorhel
f8fe53cba9 json_format: Add html_safe option 2025-03-16 15:03:32 +01:00
Yorhel
3fad7feec3 Validate: Rename "values"->"elems", repurpose "values" to validate hash values
I'm breaking stuff left and right while I still can.

Idea: "key_names" validation?

Idea: "tuple" validation that works like "keys" but for arrays.
  (i.e. { tuple => { $index => $schema } }, could make "missing" and
  "unknown" work for arrays, too)
2025-03-14 16:52:33 +01:00
Yorhel
fa24ca53e3 Validate: improved arrayref-schema semantics
This allows all built-in options to be duplicated inside a single
schema, the semantics of which are the same as the kind of merging
done as part of inheriting options from custom validations.

This also causes all 'keys' and 'values' validation schemas to be
merged, which changes error messages a bit but is great for
introspection. Probably slightly improves performance as well.
2025-03-14 14:28:28 +01:00
Yorhel
cea691dd55 Validate: drop creation of default values for built-ins
To better support merging multiple validations, which'll come next.
Probably.
2025-03-14 10:52:12 +01:00
Yorhel
f248a33c1c Validate: Allow multiple func validations in arrayref schema 2025-03-14 09:25:56 +01:00
Yorhel
1363e11269 Validate: allow array schemas + defer known_keys hash creation
Doesn't allow multiple 'func' options yet, needs work.
2025-03-14 07:28:11 +01:00
Yorhel
64a105e013 Validate: remove a level of indirection 2025-03-14 07:27:59 +01:00
Yorhel
9685287523 Version 0.3 2025-03-10 12:43:02 +01:00
Yorhel
d9d2ad0434 Pg: Add COPY support 2025-03-10 12:32:14 +01:00
Yorhel
17176738a0 FU: Support multipart file uploads + some doc fixes
API is not super convenient and implementation is lousy, but uploading
files is not a super common operation so that should be fine.

At least it supports large files with only a single in-memory copy.
2025-03-08 14:06:10 +01:00