mirror of
https://github.com/reconurge/flowsint.git
synced 2026-07-16 00:52:35 -05:00
[PR #163] [MERGED] fix(import): preserve apostrophes in valid JSON imports #3851
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/reconurge/flowsint/pull/163
Author: @Mubashirrrr
Created: 6/3/2026
Status: ✅ Merged
Merged: 6/3/2026
Merged by: @dextmorgn
Base:
main← Head:fix/json-import-apostrophe-corruption📝 Commits (1)
1fdbdbdfix(import): preserve apostrophes in valid JSON imports📊 Changes
2 files changed (+46 additions, -2 deletions)
View changed files
📝
flowsint-core/src/flowsint_core/imports/json/parse_json.py(+9 -2)📝
flowsint-core/tests/import/json/test_json_import.py(+37 -0)📄 Description
Bug
parse_json(flowsint-core/src/flowsint_core/imports/json/parse_json.py) unconditionally rewrote the file before parsing:Replacing every single quote with a double quote corrupts any valid JSON string value that contains an apostrophe — extremely common in OSINT data (names, org names, free-text). For example a node label
"Sarah O'Brien"becomes"Sarah O"Brien", which is no longer valid JSON, sojson.loadsraises and the whole import is rejected withInvalid JSON: Expecting ',' delimiter ....Reproduction
This is well-formed JSON — it should always import.
Fix
Parse strict JSON first (handles all valid JSON, apostrophes included). Only if that fails, fall back to the original lenient single-quote→double-quote replacement, preserving support for Python-dict-style payloads that aren't valid JSON on their own. Minimal, surgical change confined to the decode/parse step.
Regression tests
Added to
tests/import/json/test_json_import.py:test_json_import_preserves_apostrophes_in_string_values— fails before this change (raisesInvalid JSON), passes after.test_json_import_still_accepts_single_quoted_payload— confirms the single-quoted fallback still works.Full
tests/import/suite: 46 passed (44 pre-existing + 2 new) on Python 3.12.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.