pnp / pnpframework

PnP Framework is a .NET library targeting Microsoft 365 containing the PnP Provisioning engine and a ton of other useful extensions
https://pnp.github.io/pnpframework/
MIT License
211 stars 145 forks source link

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

Open adam13hylo opened 2 years ago

adam13hylo commented 2 years ago

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

ghost commented 1 year ago

It seems the issue is still happening on PnP.Powershell v2.1.1 for SharePoint Online environment. The issue is already fixed for SPO Shell. Please follow up.

FlorianLabranche commented 1 year ago

I encountered the same issue using PnP.Framework .NET library v.1.13.0 Any idea for a workaround ?