diff --git a/plugins/sharepoint-workbench/.apm/skills/publishing-sharepoint-pages/scripts/publish-spo-page.ps1 b/plugins/sharepoint-workbench/.apm/skills/publishing-sharepoint-pages/scripts/publish-spo-page.ps1 index 2a00016..8df38d5 100644 --- a/plugins/sharepoint-workbench/.apm/skills/publishing-sharepoint-pages/scripts/publish-spo-page.ps1 +++ b/plugins/sharepoint-workbench/.apm/skills/publishing-sharepoint-pages/scripts/publish-spo-page.ps1 @@ -24,7 +24,7 @@ the page first unless -ExistingPageBackupAction NoBackup. - JSON execution plan, or JSON results after a gated tenant publication .FUNCTION INDEX -Get-SpoPageIdentity, Get-SpoAssetServerRelativePath, Get-SpoImagePixelSize, +Get-SpoPageIdentity, Get-SpoAssetServerRelativePath, Get-SpoSitePageFileRefQuery, Get-SpoImagePixelSize, Get-SpoImageProportionalHeight, Get-SpoImageComponentUrl, ConvertTo-SpoPageHtml, New-SpoInlineImageHtml, Get-SpoInlineImageAlignment, @@ -137,6 +137,21 @@ function Get-SpoAssetServerRelativePath { return $uri.AbsolutePath } +# Builds the recursive CAML query matching one Site Pages item by its stored FileRef. +# AbsolutePath is percent-encoded ("Youth%20Court.aspx") but FileRef is stored decoded, and the +# value sits inside XML, so it must be decoded and XML-escaped (e.g. "&" -> "&"). +function Get-SpoSitePageFileRefQuery { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)][string]$SiteUrl, + [Parameter(Mandatory = $true)][string]$PageServerRelativeUrl + ) + + $fileRef = [System.Uri]::UnescapeDataString((Get-SpoAssetServerRelativePath -SiteUrl $SiteUrl -AssetPath $PageServerRelativeUrl)) + $escaped = [System.Security.SecurityElement]::Escape($fileRef) + return "$escaped" +} + # Returns the server-relative URL an Image web part points at: an image already on the # target site (ExistingImageUrl, no upload) or the package's uploaded asset (AssetPath). function Get-SpoImagePixelSize { @@ -1021,9 +1036,8 @@ function Backup-SpoExistingPage { # 3. Site Pages list item metadata + permission state. The query must be recursive (a # library query otherwise sees only the root folder) and match the full FileRef, since # the same filename can exist in several SitePages subfolders. - $pageFileRef = Get-SpoAssetServerRelativePath -SiteUrl $SiteUrl -AssetPath $PageServerRelativeUrl $listItem = Get-PnPListItem -List "Site Pages" -Query ( - "$pageFileRef" + Get-SpoSitePageFileRefQuery -SiteUrl $SiteUrl -PageServerRelativeUrl $PageServerRelativeUrl ) -ErrorAction Stop | Select-Object -First 1 if (-not $listItem) { throw "Backup could not locate the Site Pages list item for: $PageServerRelativeUrl" @@ -1594,9 +1608,8 @@ function Publish-SpoPage { if ($pageHeader) { # PnP cannot set the title zone colour: convert the saved canvas to the Banner web part model. # SystemUpdate keeps the page published (no new version, no draft). - $pageFileRef = Get-SpoAssetServerRelativePath -SiteUrl $SiteUrl -AssetPath ([string]$package.Target.PageServerRelativeUrl) $pageItem = Get-PnPListItem -List "Site Pages" -Query ( - "$pageFileRef" + Get-SpoSitePageFileRefQuery -SiteUrl $SiteUrl -PageServerRelativeUrl ([string]$package.Target.PageServerRelativeUrl) ) -ErrorAction Stop | Select-Object -First 1 if (-not $pageItem) { throw "Title banner step could not locate the Site Pages item for: $($package.Target.PageServerRelativeUrl)" diff --git a/plugins/sharepoint-workbench/tests/test_publish_page_fixes.py b/plugins/sharepoint-workbench/tests/test_publish_page_fixes.py index bb1183e..d153201 100644 --- a/plugins/sharepoint-workbench/tests/test_publish_page_fixes.py +++ b/plugins/sharepoint-workbench/tests/test_publish_page_fixes.py @@ -80,6 +80,19 @@ def test_inline_image_alignment_reads_encoded_colon(): assert done.stdout.strip() == "Center" +@pytest.mark.parametrize("page_path, expected_value", [ + ("/SitePages/CourtAdmin/Youth Court.aspx", "/sites/X/SitePages/CourtAdmin/Youth Court.aspx"), + ("/SitePages/Incidents-&-Reporting.aspx", "/sites/X/SitePages/Incidents-&-Reporting.aspx"), + ("/SitePages/Rules-(Child,-Family).aspx", "/sites/X/SitePages/Rules-(Child,-Family).aspx"), +]) +def test_site_pages_fileref_query_uses_decoded_xml_escaped_path(page_path, expected_value): + done = run_publisher_snippet( + f"Get-SpoSitePageFileRefQuery -SiteUrl 'https://t.sharepoint.com/sites/X' -PageServerRelativeUrl '{page_path}'") + assert done.returncode == 0, done.stderr + assert f"{expected_value}" in done.stdout + assert "%20" not in done.stdout + + @pytest.mark.parametrize("existing, ok", [ ("[pscustomobject]@{ Text = '' }", False), ("[pscustomobject]@{ Text = '

 

' }", False), diff --git a/references/map-debt.md b/references/map-debt.md index 4d3e133..4bb6ab5 100644 --- a/references/map-debt.md +++ b/references/map-debt.md @@ -66,3 +66,13 @@ Persistent tracking of architectural friction, structural anomalies, and unclose | DEBT-20261104-08 | Weakly structured documents had no summaries or hierarchical index for progressive discovery | PARTIAL | M | NO | 2026-11-04 | Step 3 of 4. `scripts/enrichment/navigation.py` (agent-mediated): per-topic summaries with keywords and synonyms, chapter/document roll-up and relations built from summaries only, `index.md`, `chapters/`, `navigation.json`, all carrying the AI notice and discovery-only metadata; human approval and a clean validation (notice, trust, pages, links, staleness) gate `publish`. Worked example in `assets/examples/enrichment-example/` built by `build_example.py`. Tests in `test_enrichment_navigation.py`. **Open:** evaluation mode and trust-model docs (PR 4). | this PR | | DEBT-20261104-09 | No way to measure whether structure and AI navigation aids help an agent reach authoritative content | RESOLVED | M | NO | 2026-11-04 | Step 4 of 4. `scripts/enrichment/evaluation.py` compares four arms (native PDF, large Markdown, topic Markdown, topic Markdown plus navigation): agent-mediated task files, run-record validation, deterministic scoring (retrieval accuracy, completeness, citation correctness, tokens, latency, files retrieved, answer length, failures to reach source) and a per-arm report. Trust model and optional workflow documented in `references/enrichment-trust-model.md`. Tests in `test_enrichment_evaluation.py`. **Open:** no evaluation has been run on a real corpus; results would apply to that corpus and agent only. | this PR | | DEBT-20261105-10 | Page publish: link mapping rewrote uploaded image paths, recovery published an empty shell, `:` styles unread | RESOLVED | M | NO | 2026-11-05 | Found migrating CSB news messages. The planner link mapper rewrote manifest `SiteAssets/...` image paths when the page sat under a mapped `/Pages/` prefix (now left untouched); `-RecoverPartialPage` accepted any single component and published an empty shell (now `Assert-SpoRecoverableComponent` refuses); image size and alignment readers ignored SharePoint's `:` for `:` (now decoded); the planner design-token wrapper had no opt-out (`-NoBcDesignTokens`); the contract wrongly required `-OutputPath` on the single-page publisher. Tests in `test_publish_page_fixes.py`. **Open:** recovery refusal is unit-tested only, not run against a tenant. | this PR | + +## Publish backup FileRef lookup — 2026-11-10 + +- Logged date: 2026-11-10 +- Artifact affected: publishing-sharepoint-pages/scripts/publish-spo-page.ps1 (backup and title-banner Site Pages lookups) +- Friction observed: overwriting a page whose name contains a space aborted at backup; the CAML FileRef value was percent-encoded and not XML-escaped. +- Fix: Get-SpoSitePageFileRefQuery decodes and XML-escapes the path; regression test added in tests/test_publish_page_fixes.py. Live DEV re-run pending. +- Severity: M +- Repeat: NO +- Status: RESOLVED