sheetjs_sheetjs/bits
deepak-negi-web 5550b90704 fix: infinite loop due to hidden row in XLSX.stream.to_json (#3178)
**Title:**

Fix for Incorrect Row Indexing and Infinite Loop in stream.to_json Function

**Description:**

This pull request addresses two key issues in the `stream.to_json` function of the SheetJS library:

1. **Infinite Loop**: Previously, when a row was hidden, the function skipped processing the current row without incrementing the row counter `R`, resulting in an infinite loop during execution.

2. **Incorrect Row Indexing**: The row index was incorrectly accessed using a one-based index, whereas the actual row index was zero-based. This led to unintended hidden rows being included in the stream and skipping of subsequent non-hidden rows.

**Changes:**

- Modified the hidden row check to use the correct zero-based indexing
- Incremented `R` after identifying a hidden row to ensure the loop progresses to the next row.
- Ensured that the stream correctly processes all rows, skipping hidden rows without affecting subsequent rows.

**Testing:**

- Validated that the `stream.to_json` function no longer enters an infinite loop when encountering hidden rows.
- Confirmed that the correct rows are processed and pushed to the stream, with hidden rows being appropriately skipped.

**Impact:**

This fix enhances the reliability of the SheetJS library, ensuring accurate data streaming from spreadsheets without infinite loops or incorrect row handling.

**Checklist:**

- [x] Code changes have been tested locally.
- [x] The changes adhere to the project's coding standards and guidelines.

**Additional Information:**

These changes are crucial for maintaining the library's functionality in production environments, where precise data handling is essential.

**References:**

Closes #3176.

---

Reviewed-on: sheetjs/sheetjs#3178
Co-authored-by: deepak-negi-web <deepak-negi-web@noreply.git.sheetjs.com>
Co-committed-by: deepak-negi-web <deepak-negi-web@noreply.git.sheetjs.com>
2024-08-21 05:34:31 +00:00
..
.npmignore version bump 0.8.0: unification with js-xls 0.7.5 2015-04-02 16:32:22 -04:00
01_version.js version bump 0.20.3 2024-07-12 11:47:14 -04:00
02_codepage.js remove flow array comment workarounds 2024-02-02 01:52:14 -05:00
03_consts.js version bump 0.9.13: string formatting 2017-04-30 12:27:03 -04:00
04_base64.js remove flow array comment workarounds 2024-02-02 01:52:14 -05:00
05_buf.js version bump 0.18.12 2022-09-22 05:06:45 -04:00
09_types.js "side-effect free" 2022-03-19 21:54:41 -04:00
10_ssf.js NaN and Infinity error export 2024-07-04 15:54:34 -04:00
11_ssfutils.js version bump 0.20.0 2023-06-23 05:48:47 -04:00
18_cfb.js NaN and Infinity error export 2024-07-04 15:54:34 -04:00
19_fsutils.js remove flow array comment workarounds 2024-02-02 01:52:14 -05:00
20_jsutils.js version bump 0.20.2 2024-04-04 21:30:28 -04:00
21_ziputils.js NaN and Infinity error export 2024-07-04 15:54:34 -04:00
22_xmlutils.js XLSX encoded entities (fixes #3177) 2024-08-19 12:43:37 -04:00
23_binutils.js Ś╫êëτ⌡ś and Š╫ěéτ⌡š 2022-09-09 16:59:22 -04:00
24_hoppers.js NaN and Infinity error export 2024-07-04 15:54:34 -04:00
25_cellutils.js version bump 0.15.6: niggles from 2012 2020-03-15 03:57:44 -04:00
26_cptable.js version bump 0.18.8: dateless meridien time values 2022-05-22 19:51:41 -04:00
27_csfutils.js NaN and Infinity error export 2024-07-04 15:54:34 -04:00
28_binstructs.js version bump 0.18.3 2022-03-03 03:35:39 -05:00
29_xlsenum.js remove flow array comment workarounds 2024-02-02 01:52:14 -05:00
30_ctype.js version bump 0.18.8: dateless meridien time values 2022-05-22 19:51:41 -04:00
31_rels.js version bump 0.19.2 2023-01-25 16:17:34 -05:00
32_odmanrdf.js build fixes for macOS Ventura 2023-04-14 03:51:02 -04:00
33_coreprops.js remove flow array comment workarounds 2024-02-02 01:52:14 -05:00
34_extprops.js remove flow array comment workarounds 2024-02-02 01:52:14 -05:00
35_custprops.js version bump 0.20.2 2024-04-04 21:30:28 -04:00
36_xlsprops.js phasing out patterns with side effects 2022-03-14 02:51:33 -04:00
38_xlstypes.js XLML Streaming Write 2024-05-31 03:16:53 -04:00
39_xlsbiff.js remove flow array comment workarounds 2024-02-02 01:52:14 -05:00
40_harb.js NaN and Infinity error export 2024-07-04 15:54:34 -04:00
41_lotus.js NaN and Infinity error export 2024-07-04 15:54:34 -04:00
42_sstxml.js version bump 0.20.2 2024-04-04 21:30:28 -04:00
43_sstbin.js XLSB/XLS Record Name refactor 2022-03-12 09:05:57 -05:00
44_offcrypto.js XLSB/XLS Record Name refactor 2022-03-12 09:05:57 -05:00
45_rtf.js NaN and Infinity error export 2024-07-04 15:54:34 -04:00
46_stycommon.js version bump 0.11.18: infrastructure 2018-01-23 04:07:55 -05:00
47_styxml.js merge nits (fixes #3142 h/t @s-ashwin ) 2024-07-11 01:33:25 -04:00
48_stybin.js Fix bad google sheets format 'd.m' 2022-04-05 19:14:12 -07:00
49_theme.js version bump 0.20.2 2024-04-04 21:30:28 -04:00
50_styxls.js version bump 0.17.3 2021-10-13 03:26:40 -04:00
51_xlsbmeta.js version bump 0.18.4 2022-03-15 23:23:39 -04:00
51_xlsxmeta.js package.json exports types 2022-09-21 18:17:14 -04:00
52_calcchain.js XLSB/XLS Record Name refactor 2022-03-12 09:05:57 -05:00
53_externlink.js XLSB/XLS Record Name refactor 2022-03-12 09:05:57 -05:00
54_drawing.js remove flow array comment workarounds 2024-02-02 01:52:14 -05:00
55_vml.js version bump 0.20.2 2024-04-04 21:30:28 -04:00
56_cmntcommon.js XLSX Ensure comment address is valid 2023-04-12 03:48:54 -04:00
57_cmntxml.js version bump 0.20.2 2024-04-04 21:30:28 -04:00
58_cmntbin.js cell comments 2023-06-13 00:49:18 -04:00
59_vba.js version bump 0.20.2 2024-04-04 21:30:28 -04:00
60_macrovba.js phasing out patterns with side effects 2022-03-14 02:51:33 -04:00
61_fcommon.js QPW string formula results 2023-10-15 23:03:39 -04:00
62_fxls.js remove flow array comment workarounds 2024-02-02 01:52:14 -05:00
63_fbin.js version bump 0.20.0 2023-06-23 05:48:47 -04:00
64_ftab.js README cleanup in anticipation of node fetch 2022-02-05 09:04:02 -05:00
65_fods.js version bump 0.20.0 2023-06-23 05:48:47 -04:00
66_wscommon.js version bump 0.20.0 2023-06-23 05:48:47 -04:00
67_wsxml.js NaN and Infinity error export 2024-07-04 15:54:34 -04:00
68_wsbin.js NaN and Infinity error export 2024-07-04 15:54:34 -04:00
69_chartxml.js version bump 0.20.2 2024-04-04 21:30:28 -04:00
70_csheet.js version bump 0.18.6 2022-04-14 03:27:38 -04:00
71_wbcommon.js version bump 0.19.3 2023-04-17 23:39:28 -04:00
72_wbxml.js XLSB/XLS Record Name refactor 2022-03-12 09:05:57 -05:00
73_wbbin.js remove flow array comment workarounds 2024-02-02 01:52:14 -05:00
74_xmlbin.js version bump 0.18.6 2022-04-14 03:27:38 -04:00
75_xlml.js NaN and Infinity error export 2024-07-04 15:54:34 -04:00
76_xls.js do not bail when XLS properies cannot be parsed 2024-07-17 14:23:02 -04:00
77_parsetab.js remove flow array comment workarounds 2024-02-02 01:52:14 -05:00
78_writebiff.js XLML Streaming Write 2024-05-31 03:16:53 -04:00
79_html.js XLSX encoded entities (fixes #3177) 2024-08-19 12:43:37 -04:00
80_parseods.js XLSX encoded entities (fixes #3177) 2024-08-19 12:43:37 -04:00
81_writeods.js XLSX encoded entities (fixes #3177) 2024-08-19 12:43:37 -04:00
83_numbers.js version bump 0.20.3 2024-07-12 11:47:14 -04:00
84_defaults.js phasing out patterns with side effects 2022-03-14 02:51:33 -04:00
85_parsezip.js version bump 0.20.2 2024-04-04 21:30:28 -04:00
86_writezip.js cell comments 2023-06-13 00:49:18 -04:00
87_read.js NaN and Infinity error export 2024-07-04 15:54:34 -04:00
88_write.js parse number values from RTF cells 2022-07-07 02:30:44 -04:00
90_utils.js NaN and Infinity error export 2024-07-04 15:54:34 -04:00
95_api.js xlsx-cli v1.1.4 2023-10-11 16:22:42 -04:00
97_node.js fix: infinite loop due to hidden row in XLSX.stream.to_json (#3178) 2024-08-21 05:34:31 +00:00
98_exports.js Add ESM helper methods to CJS build (fixes #2909) 2023-04-10 01:15:44 -04:00
99_footer.js very basic numbers iwa parser 2022-01-28 21:54:11 -05:00
00_header.js SYLK error cells read/write (fixes #3049) 2024-01-10 04:54:10 -05:00