Skip to content

Commit

Permalink
Merge pull request #51 from ndtoan96/main
Browse files Browse the repository at this point in the history
Fix control character bug
  • Loading branch information
xoofx authored Dec 22, 2022
2 parents d64a5d2 + 9b7acdd commit aede648
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/Tomlyn.Tests/ValidatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,16 @@ public void TestTableArrayAndInvalidTable()
Assert.True(doc.HasErrors, "The document should have errors");
}

[Test]
public void TestAllowTab()
{
var input = "";
input += "tab_multiline_basic=\"\"\"\t\"\"\"\n";
input += "tab_singleline_literal='\t'\n";
input += "tab_multiline_literal='''\t'''\n";
var doc = Toml.Parse(input);
Assert.False(doc.HasErrors, "The document should not have errors");
}

}
}
2 changes: 1 addition & 1 deletion src/Tomlyn/Parsing/Lexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ private void ReadStringLiteral(TextPosition start, bool allowMultiline)
{
AddError("Invalid newline in a string", _position, _position);
}
else if (CharHelper.IsControlCharacter(_c) && (!isMultiLine || !CharHelper.IsNewLine(_c)))
else if (CharHelper.IsControlCharacter(_c) && _c != '\t' && (!isMultiLine || !CharHelper.IsNewLine(_c)))
{
AddError($"Invalid control character found {((char)_c).ToPrintableString()}", start, start);
}
Expand Down

0 comments on commit aede648

Please sign in to comment.