|
6 | 6 | use std::path::Path; |
7 | 7 |
|
8 | 8 | use serde_json::Value; |
9 | | -use toml_edit::{DocumentMut, Item, TableLike}; |
| 9 | +use toml_edit::{Item, Table, TableLike}; |
10 | 10 |
|
11 | 11 | use crate::crawlers::python_crawler::canonicalize_pypi_name; |
12 | 12 | use crate::formats::text::strip_bom; |
@@ -326,7 +326,8 @@ pub(super) fn portable_wheel_artifact( |
326 | 326 | } |
327 | 327 |
|
328 | 328 | pub(super) fn python_lock_inventory(text: &str) -> Option<Vec<LockfileEntry>> { |
329 | | - let document: DocumentMut = text.parse().ok()?; |
| 329 | + // Read-only parse, as in lockfile discovery (`toml_or_diag`, #1473). |
| 330 | + let document = toml_edit::Document::parse(text).ok()?; |
330 | 331 | let (collection, pep751) = lock_package_collection(&document); |
331 | 332 | // Only the lock formats the fetch layer understands. |
332 | 333 | let supported = if pep751 { |
@@ -395,7 +396,7 @@ pub(super) fn python_lock_inventory(text: &str) -> Option<Vec<LockfileEntry>> { |
395 | 396 | /// can be chosen there). A lock that is not TOML contributes nothing. |
396 | 397 | async fn inventory_poetry_lock(view: &ProjectView<'_>) -> Option<Vec<LockfileEntry>> { |
397 | 398 | let text = view.read_text("poetry.lock").await.ok()?; |
398 | | - let document: DocumentMut = text.parse().ok()?; |
| 399 | + let document = toml_edit::Document::parse(text.as_str()).ok()?; |
399 | 400 | let pure_wheel_sha = |files: Vec<&dyn TableLike>| { |
400 | 401 | files.into_iter().find_map(|entry| { |
401 | 402 | let file = entry.get("file")?.as_str()?; |
@@ -429,7 +430,7 @@ async fn inventory_poetry_lock(view: &ProjectView<'_>) -> Option<Vec<LockfileEnt |
429 | 430 |
|
430 | 431 | /// `(canonical name, version, purl, table)` of every path-safe `[[package]]` |
431 | 432 | /// of a poetry.lock / pdm.lock document. |
432 | | -fn toml_package_coords(document: &DocumentMut) -> Vec<(String, String, String, &toml_edit::Table)> { |
| 433 | +fn toml_package_coords(document: &Table) -> Vec<(String, String, String, &Table)> { |
433 | 434 | let Some(packages) = document.get("package").and_then(Item::as_array_of_tables) else { |
434 | 435 | return Vec::new(); |
435 | 436 | }; |
@@ -588,7 +589,7 @@ async fn inventory_pipfile_lock(view: &ProjectView<'_>) -> Option<Vec<LockfileEn |
588 | 589 | /// does not probe, so a lock-only vendored path would not survive a re-scan. |
589 | 590 | async fn inventory_pdm_lock(view: &ProjectView<'_>) -> Option<Vec<LockfileEntry>> { |
590 | 591 | let text = view.read_text("pdm.lock").await.ok()?; |
591 | | - let document: DocumentMut = text.parse().ok()?; |
| 592 | + let document = toml_edit::Document::parse(text.as_str()).ok()?; |
592 | 593 | let out: Vec<LockfileEntry> = toml_package_coords(&document) |
593 | 594 | .into_iter() |
594 | 595 | .map(|(name, version, purl, _)| LockfileEntry { |
|
0 commit comments