U4-6043 Error parsing package.manifest value Path line 0 position 0

Added a unit test and updated the logic as it was doing the wrong thing
#U4-6043 Fixed
This commit is contained in:
Sebastiaan Janssen
2015-08-19 19:11:20 +02:00
parent 08ddb5f4c4
commit f3a965841b
2 changed files with 15 additions and 7 deletions

View File

@@ -141,12 +141,17 @@ namespace Umbraco.Core.Manifest
{
var result = new List<PackageManifest>();
foreach (var m in manifestFileContents)
{
// Strip byte object marker, JSON.NET does not like it
{
var manifestContent = m;
var preAmble = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
if (manifestContent.StartsWith(preAmble))
manifestContent = manifestContent.Remove(0, preAmble.Length);
if (manifestContent.IsNullOrWhiteSpace()) continue;
// Strip byte object marker, JSON.NET does not like it
var preamble = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
// Strangely StartsWith(preamble) would always return true
if (manifestContent.Substring(0, 1) == preamble)
manifestContent = manifestContent.Remove(0, preamble.Length);
if (manifestContent.IsNullOrWhiteSpace()) continue;

View File

@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -460,13 +461,15 @@ javascript: ['~/test.js',/*** some note about stuff asd09823-4**09234*/ '~/test2
var content2 = "{javascript: []}";
var content3 = "{javascript: ['~/test.js', '~/test2.js']}";
var content4 = "{propertyEditors: [], javascript: ['~/test.js', '~/test2.js']}";
var content5 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble()) + "{propertyEditors: [], javascript: ['~/test.js', '~/test2.js']}";
var result = ManifestParser.CreateManifests(null, content1, content2, content3, content4);
var result = ManifestParser.CreateManifests(null, content1, content2, content3, content4, content5);
Assert.AreEqual(4, result.Count());
Assert.AreEqual(5, result.Count());
Assert.AreEqual(0, result.ElementAt(1).JavaScriptInitialize.Count);
Assert.AreEqual(2, result.ElementAt(2).JavaScriptInitialize.Count);
Assert.AreEqual(2, result.ElementAt(3).JavaScriptInitialize.Count);
Assert.AreEqual(2, result.ElementAt(4).JavaScriptInitialize.Count);
}
[Test]