Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRoblem with Literal Blocks?? #535

Open
DynConcepts opened this issue Sep 30, 2020 · 3 comments
Open

PRoblem with Literal Blocks?? #535

DynConcepts opened this issue Sep 30, 2020 · 3 comments
Labels

Comments

@DynConcepts
Copy link

THe following snippet passes external validation/lint.... but fails...

`- task: manognaalla.ppmsigntool-task.PPMSignTool.PPMSignTool@4
displayName: 'Run PPMSignTool on CompressionUtils.dll'
inputs:
FilePath: 'bin$(BuildPlatform)$(BuildConfiguration)\CompressionUtils.dll'
ConfigInput: InlineArg
CompanyName: 'Hexagon, Hexagon PPM'
ProductName: 'HxGN 3D GDS'
LegalCopyRight: |

Arguments: force
SHA256: false

condition: and(succeeded(), eq(variables['BuildConfiguration'], 'Release'))
`

Throws exception when it encounters the "A" in Arguments...

if (isLiteral && indentOfFirstLine > 1 && currentIndent < indentOfFirstLine - 1) { // W9L4 throw new SemanticErrorException(end, cursor.Mark(), "While scanning a literal block scalar, found extra spaces in first line."); }

@DynConcepts
Copy link
Author

Himalaya-CI.yaml.txt

@EdwardCooke
Copy link
Collaborator

Thanks for the yaml example, it's much appreciated. I have simplified it down to a very small yaml example that breaks.

using YamlDotNet.Serialization;

var deserializer = new DeserializerBuilder().Build();

var yaml = @"a:
- b: |
    
    
  c: d
";

var a = deserializer.Deserialize<object>(yaml);

@ranma42
Copy link

ranma42 commented Sep 17, 2024

another simple example is

// @nuget: YamlDotNet -Version 16.1.2

ToJson("|\n\n  foo\n"); // prints "\nfoo\n"
ToJson("|\n \n  bar\n"); // prints "\nbar\n"

ToJson("|\n  \n  baz\n"); // should print "\nbaz\n"
// but fails While scanning a literal block scalar, found extra spaces in first line.

ToJson("|\n   \n  nope\n");
// fails as expected with While scanning a literal block scalar, found extra spaces in first line.

void ToJson(string s) {
	var deserializer = new YamlDotNet.Serialization.DeserializerBuilder().Build();
	try {
		var json = System.Text.Json.JsonSerializer.Serialize(deserializer.Deserialize<string>(s));
		System.Console.WriteLine(s);
	} catch (System.Exception e) {
		System.Console.WriteLine(e);
	}
}

(formatted so that it can be trivially used in https://dotnetfiddle.net/# )

@EdwardCooke is this considered a bug? Would you accept a PR adding a test and fix for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants