evidence-dev / evidence

Business intelligence as code: build fast, interactive data visualizations in pure SQL and markdown
https://evidence.dev
MIT License
4.46k stars 214 forks source link

[Bug]: html comments in .md files improperly parsed #2510

Open kennan-simpliphy opened 2 months ago

kennan-simpliphy commented 2 months ago

Describe the bug

<!-- <script>
</script> -->

This was crashing my app

Steps to Reproduce

---
title: myTitle
queries:
  - myQuery1.sql
  - myQuery2.sql
---

<!-- <script>
</script> -->

^ Even with valid queries, this .md file crashes the app and throws an error saying that the queries are not found. Uncommenting the script tags fixes the problem.

Logs

3:29:39 PM [vite] Internal server error: 'myQuery1' is not defined

System Info

System:
    OS: macOS 14.3
    CPU: (14) arm64 Apple M3 Max
    Memory: 3.98 GB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.asdf/installs/nodejs/20.12.2/bin/node
    Yarn: 1.22.22 - ~/.asdf/installs/nodejs/20.12.2/bin/yarn
    npm: 10.8.0 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chrome: 128.0.6613.120
    Safari: 17.3
  npmPackages:
    @evidence-dev/bigquery: ^2.0.7 => 2.0.7 
    @evidence-dev/core-components: ^4.7.8 => 4.7.8 
    @evidence-dev/csv: ^1.0.12 => 1.0.12 
    @evidence-dev/databricks: ^1.0.7 => 1.0.7 
    @evidence-dev/duckdb: ^1.0.11 => 1.0.11 
    @evidence-dev/evidence: ^39.1.5 => 39.1.5 
    @evidence-dev/motherduck: ^1.0.2 => 1.0.2 
    @evidence-dev/mssql: ^1.0.9 => 1.0.9 
    @evidence-dev/mysql: ^1.1.3 => 1.1.3 
    @evidence-dev/postgres: ^1.0.6 => 1.0.6 
    @evidence-dev/snowflake: ^1.1.0 => 1.1.0 
    @evidence-dev/sqlite: ^2.0.6 => 2.0.6 
    @evidence-dev/trino: ^1.0.8 => 1.0.8

Severity

blocking all usage of Evidence

Additional Information, or Workarounds

No response

csjh commented 2 months ago

This is because we have a fairly naive check for whether or not the script tag has been defined. Should work for any comments that don't contain <script>. For now I would suggest commenting out the contents of the script tag rather than the tag itself.