
Safe Loaders in Python Ruby and Java Compared and Tested
Which function to call in PyYAML, Ruby Psych and SnakeYAML to load untrusted YAML safely, what each default does and how to grep for the unsafe ones.
Tag
590 posts

Which function to call in PyYAML, Ruby Psych and SnakeYAML to load untrusted YAML safely, what each default does and how to grep for the unsafe ones.

Remove personal data from an Excel file before sharing: drop author properties, mask or delete columns, clear comments and rebuild a clean copy by script.

Wrapper elements, empty versus absent versus nil, and the one-item list trap when XML becomes JSON, all demonstrated with real parser output.

Swift has no CSV parser in Foundation, and its String treats CRLF as one Character, so splitting on a newline fails. Parse bytes or use SwiftCSV.

Turn a JSON array into rows in BigQuery with UNNEST and JSON_QUERY_ARRAY or JSON_VALUE_ARRAY, with positions, empty arrays, nesting and filters.

Find hidden sheets, document properties, comments, defined names and pivot caches in a workbook before you share it, with a script that audits the file.

Read a CSV in Kotlin with kotlin-csv and build a small import job that validates rows, rejects bad ones with row numbers and never hides a failure.

Version attribute or new namespace? Test results show how strict schemas reject added elements and how an extension point lets old readers keep working.

A bash read loop on a CSV breaks on quoted commas, backslashes, a missing last newline and empty tab fields. Let a CSV parser emit safe records first.

Build a 378-byte YAML document that expands to 34 MB, measure PyYAML, DuckDB and Go on it, and see which parsers fail early and which wait for the output.

Read JSON in BigQuery with JSON_VALUE, JSON_QUERY, field access and typed converters such as INT64(), with the null rules, SAFE prefix and lax conversion.

Parse CSV in Ruby 3.4 with the csv gem: the Gemfile LoadError, a numeric converter that read 02134 as 1116, nil versus empty strings, and timings.