Skip to content

StudioViews.Services.ProjectFileService: Update GetProjectFiles to avoid silent fail  #1681

Open
@murxh

Description

public List<ProjectFileInfo> GetProjectFiles(string filePath)

ProjectFileService.GetProjectFiles fails silently if it encounters invalid xml chars (like 0x1C, 0x1E, ...), resulting in an empty export file without any warning to the user
An easy fix would be to use XmlReaderSettings { CheckCharacters = false };

Instead of var xml = XDocument.Load(filePath, LoadOptions.PreserveWhitespace);

  XDocument xml = null;
  // avoid System.Xml.XmlException Message: '?', hexadecimal value 0x1C, 0x1E, ... is an invalid character.
  XmlReaderSettings xmlReaderSettings = new XmlReaderSettings { CheckCharacters = false };
  using (XmlReader xmlReader = XmlReader.Create(filePath, xmlReaderSettings))
  {
    xmlReader.MoveToContent();
    xml = XDocument.Load(xmlReader, LoadOptions.PreserveWhitespace);
  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions