You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the last character of a folded string is the end of the file and there's nothing else following it, the parsed token's Value field doesn't contain that last character.
To Reproduce
This is a strange case. Apparently, some editors strip the line feed character from the last line of the file even if that line is not empty. I am going to illustrate it with $ to denote the invisible line feed characters (ASCII 0a).
Normally, the file contents would look like the following and foo is correctly parsed as bar.
foo: >$ bar$
However, the following YAML file produces ba as the value of foo. Note that there's no line feed following bar. Your editor would normally add the line feed automatically so you need to remove it by running truncate -s -1 file.yaml to reproduce this.
foo: >$ bar
Expected behavior
Folded strings should not be truncated if there's no trailing whitespace.
Version Variables
Go version: 1.22.1
go-yaml's Version: 1.11.3 and master
Additional context
I have a patch ready and can raise a PR to fix this.
The text was updated successfully, but these errors were encountered:
As described in goccy#433, if the last character of a folded string is the
very last character in the file (no trailing whitespace), it's not
included the token's `Value`.
While fixing this, I also noticed that the column information for the
folded and literal strings were the end rather than the beginning. I've
(hopefully) fixed that as well.
Fixesgoccy#433
Signed-off-by: Charith Ellawala <[email protected]>
As described in goccy#433, if the last character of a folded string is the
very last character in the file (no trailing whitespace), it's not
included the token's `Value`.
While fixing this, I also noticed that the column information for the
folded and literal strings were the end rather than the beginning. I've
(hopefully) fixed that as well.
Fixesgoccy#433
Signed-off-by: Charith Ellawala <[email protected]>
charithe
added a commit
to charithe/go-yaml
that referenced
this issue
Jul 22, 2024
As described in goccy#433, if the last character of a folded string is the
very last character in the file (no trailing whitespace), it's not
included the token's `Value`.
While fixing this, I also noticed that the column information for the
folded and literal strings were the end rather than the beginning. I've
(hopefully) fixed that as well.
Fixesgoccy#433
Signed-off-by: Charith Ellawala <[email protected]>
Describe the bug
If the last character of a folded string is the end of the file and there's nothing else following it, the parsed token's
Value
field doesn't contain that last character.To Reproduce
This is a strange case. Apparently, some editors strip the line feed character from the last line of the file even if that line is not empty. I am going to illustrate it with
$
to denote the invisible line feed characters (ASCII 0a).Normally, the file contents would look like the following and
foo
is correctly parsed asbar
.However, the following YAML file produces
ba
as the value offoo
. Note that there's no line feed followingbar
. Your editor would normally add the line feed automatically so you need to remove it by runningtruncate -s -1 file.yaml
to reproduce this.Expected behavior
Folded strings should not be truncated if there's no trailing whitespace.
Version Variables
master
Additional context
I have a patch ready and can raise a PR to fix this.
The text was updated successfully, but these errors were encountered: