Skip to content

Commit 521cd8b

Browse files
fix(fs): off by one error in readTextFileLines (#3155)
* fix: off by one error in readTextFileLines (#3154) Signed-off-by: EliasStar <31409841+EliasStar@users.noreply.github.com> * Format and regenerate `api-iife.js` --------- Signed-off-by: EliasStar <31409841+EliasStar@users.noreply.github.com> Co-authored-by: Tony <legendmastertony@gmail.com>
1 parent e4a40f4 commit 521cd8b

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"fs": patch
3+
"fs-js": patch
4+
---
5+
6+
Fix off by one error in the implementation of readTextFileLines causing all lines to end with an (additional) null byte.
7+
Issue: [#3154](https://github.com/tauri-apps/plugins-workspace/issues/3154)
8+
PR: [#3155](https://github.com/tauri-apps/plugins-workspace/pull/3155)

plugins/fs/api-iife.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/fs/guest-js/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,9 @@ async function readTextFileLines(
838838
return { value: null, done }
839839
}
840840

841-
const line = new TextDecoder().decode(bytes.slice(0, bytes.byteLength))
841+
const line = new TextDecoder().decode(
842+
bytes.slice(0, bytes.byteLength - 1)
843+
)
842844

843845
return {
844846
value: line,

0 commit comments

Comments
 (0)