Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-DIAG-122

Chart data files are read through the resource policy

When a Vega-Lite or Vega chart names a relative data url, the extension SHALL read that file under the rules of the include directive (inside the document folder or workspace, no symlink escape, at most 5 MiB), hand its text to the page with the chart, and refuse every remote url with a message.

Another outcome at step 1 of path 1 in StRS-MDOKFSTUDIO-DIAG-015, in the state “A document holds a Vega-Lite or Vega fence”.

Scenarios 3

The situations the tests check; open one to read it.

nominalA relative data file
Givena document in a workspace folder and a vega-lite chart with data.url data/rows.csv, a file next to the document
Whenthe preview renders
Thenthe chart element carries the text of the file in data-myst-chart-files under the url as written, the file is a dependency of the render (the preview renders again when it changes), and the page draws the rows of the file; a CSV or TSV file is parsed by the extension without evaluating code, a JSON file as JSON
refusalA remote url
Givena chart whose data url starts with https:, http:, file: or //
Whenthe preview renders and the page draws the chart
Thennothing is read and no request is made (connect-src stays none), and the chart shows the message Remote chart data is not loaded followed by the url
refusalA file outside the folders, missing, too large or of another format
Givena data url that the allowed-roots rule (SwRS-MDOKFSTUDIO-TRUST-025) refuses, names a missing file, an absolute path or a file larger than 5 MiB, or names a format other than csv, tsv or json
Whenthe preview renders
Thenno file text is handed to the page, a warning diagnostic names the refusal, and the chart shows the same message in place of the chart
InputOutcome
data.url with a relative path inside the rootsthe text is read, at most 16 files per chart, charged to the include budget
a format type of topojson or another unknown typerefused with a message naming the format
a csv or tsv filethe first record names the columns; numbers and true or false are typed

Implemented in 4

Tested by 4