tconbeer / harlequin

The SQL IDE for Your Terminal.
https://harlequin.sh
MIT License
3.71k stars 86 forks source link

JSON fields containing unicode escape sequences are potentially rendered incorrectly #635

Open gcmurphy-snyk opened 2 months ago

gcmurphy-snyk commented 2 months ago

Before Proceeding, please acknowledge:

Describe the bug

Any json field loaded from duckdb containing \n or other escape sequences may not be displayed as expected by harlequin. Leading new line characters look as empty values.

To Reproduce Steps to reproduce the behavior.

Given this file example.json:

{                                                                                                                                                                                   
  "example": "normal entry",                                                                                                                                                        
  "hidden": "\n this is hidden",                                                                                                                                                    
  "emoji": "\uD83D\uDCA9"                                                                                                                                                           
}

Run the query:

select * from read_json_auto('example.json')

Expected behavior Screenshot 2024-08-28 at 12 02 59 PM

Actual behavior

Screenshot 2024-08-28 at 12 03 50 PM

(The text in the hidden field is not visible)

Contributing Are you interested in contributing a fix?

Additional context Please provide as much as you can, but don't waste your time if it's definitely not relevant or you don't know.

What is the output of harlequin --version?

$ harlequin --version
harlequin, version 1.20.0

Installed Adapters:
  - duckdb, version 1.20.0
  - sqlite, version 1.20.0

What database adapter are you using with Harlequin? (Default is duckdb)

duckdb

What other options are you using when invoking Harlequin? (If you are using a profile, please add relevant items from your profile here).

Can you tell us more about your system?

[!TIP] For example, for my system, these are:

  • Bash
  • Windows Terminal
  • Ubuntu 22.04 / WSL2
  • Windows 11
  • en_US/UTF-8

How did you install Harlequin?

tconbeer commented 2 months ago

Thanks for the issue. The data table is truncating everything after the first line for each cell (So "foo\nbar" renders as "foo"). Escaping might be a good idea (and easier than supporting multiple lines per record).