Skip to content

Fix metaflac --import-tags-from-file, allow missing newline and \r#870

Open
madah81pnz1 wants to merge 3 commits intoxiph:masterfrom
madah81pnz1:fix-missing-newline
Open

Fix metaflac --import-tags-from-file, allow missing newline and \r#870
madah81pnz1 wants to merge 3 commits intoxiph:masterfrom
madah81pnz1:fix-missing-newline

Conversation

@madah81pnz1
Copy link
Contributor

Remove one extra feof() call since it would prevent the last line from being added if it was missing a newline at the end.

Check for both \r and \n, since otherwise the tags will be added with an extra \r included in the tag value, which is unexpected.

Fixes #856

Remove one extra feof() call since it would prevent the last line
from being added if it was missing a newline at the end.

Check for both \r and \n, since otherwise the tags will be added with
an extra \r included in the tag value, which is unexpected.

Fixes xiph#856
@ktmf01
Copy link
Collaborator

ktmf01 commented Feb 22, 2026

Hmm, the test doesn't seem to work on macos for some reason.

@madah81pnz1
Copy link
Contributor Author

Hmm, the test doesn't seem to work on macos for some reason.

That was surprising, I don't have a MacOS system available to test on locally though. I could modify the test to also print out the metadata it got, a hexdump diff.

It could be due to slight differences in shell syntax between dash and zsh, this I could try a bit on my end first.

Otherwise my guess is it has something to do with how \r was the historical line ending on MacOS. Maybe the shell on MacOS auto-translates \r it into \n, thus the \r\n in the test gets converted into \n\n.

If that's the case, I could either disable the \r\n test on MacOS, or break out the \r\n handling into another PR.

@ktmf01
Copy link
Collaborator

ktmf01 commented Feb 23, 2026

test case39: --import-tags-from=-...  
diff of expected and actual metadata:
16c16
<     comment[1]: TITLE=Tittle
---
>     comment[1]: -n TITLE=Tittle

hexdump diff of expected and actual metadata:
./test_metaflac.sh: line 134: hd: command not found
./test_metaflac.sh: line 135: hd: command not found
ERROR: metadata does not match expected ../test/metaflac-test-files/case39-expect.meta

@ktmf01
Copy link
Collaborator

ktmf01 commented Feb 23, 2026

By the way, I just remembered there is a ECHO_N shell variable for this. Take a look at the rest of the scripts for uses of this.

@madah81pnz1
Copy link
Contributor Author

By the way, I just remembered there is a ECHO_N shell variable for this. Take a look at the rest of the scripts for uses of this.

Thanks! I did know about ECHO_N, but completely missed to use it in one spot.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The --import-tags-from option of metaflac does not add the last tag if the file does not end with a newline.

2 participants