pnp / pnp/pnpframework

Get-PnPSiteTemplate crashes on ampersand (&) in document library title

Open
#618 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
259
Forks
161
Avg merge
10h 33m
Merged PRs (30d)
1

Description

Related to the following issue: https://github.com/pnp/pnpframework/issues/202

Actual behavior

When running Get-PnPSiteTemplate the script fails with the error:
Get-PnPSiteTemplate: An error occurred while parsing EntityName. Line 17, position 140.

Steps to reproduce
  1. Create a document library containing an ampersand e.g. "Testing & Manuals"
  2. Invoke the Get-PnPSiteTemplate cmdlet, including the Lists handler:
    Get-PnPSiteTemplate -Out "./pnp-template.xml" -Handlers Lists
  3. The cmdlet will fail with the following error message: "Get-PnPSiteTemplate: An error occurred while parsing EntityName. Line 17, position 140."
Full Exception

Message : An error occurred while parsing EntityName. Line 17, position 140. Stacktrace : at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, Int32 lineNo, Int32 linePos) at System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32& charRefEndPos) at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars) at System.Xml.XmlTextReaderImpl.FinishPartialValue() at System.Xml.XmlTextReaderImpl.get_Value() at System.Xml.Linq.XContainer.ContentReader.ReadContentFrom(XContainer rootContainer, XmlReader r) at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r) at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options) at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options) at PnP.Framework.Provisioning.ObjectHandlers.ObjectHandlerBase.TokenizeListView(String xml, List list, Web web) at PnP.Framework.Provisioning.ObjectHandlers.ObjectListInstance.ExtractViews(Web web, List siteList, ListInstance list, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo) at PnP.Framework.Provisioning.ObjectHandlers.ObjectListInstance.ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo) at PnP.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.GetRemoteTemplate(Web web, ProvisioningTemplateCreationInformation creationInfo) at Microsoft.SharePoint.Client.WebExtensions.GetProvisioningTemplate(Web web, ProvisioningTemplateCreationInformation creationInfo) at PnP.PowerShell.Commands.Provisioning.Site.GetSiteTemplate.ExtractTemplate(XMLPnPSchemaVersion schema, String path, String packageName, ExtractConfiguration configuration) in c:\build\src\Commands\Provisioning\Site\GetSiteTemplate.cs:line 371 at PnP.PowerShell.Commands.Provisioning.Site.GetSiteTemplate.ExecuteCmdlet() in c:\build\src\Commands\Provisioning\Site\GetSiteTemplate.cs:line 149 at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in c:\build\src\Commands\Base\PnPSharePointCmdlet.cs:line 60 ScriptLineNumber : 1

What is the version of the Cmdlet module you are running?

image

Which operating system/environment are you running PnP PowerShell on?

Windows

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ObjectHandlerBase.TokenizeListView and ObjectListInstance.ExtractViews, then trace how GetSiteTemplate.cs invokes template extraction. Reproduce with a document library titled "Testing & Manuals" and the Lists handler; done means Get-PnPSiteTemplate completes without the XML parsing error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
43/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.