Description: Assume a ReadLine(input as string) routine that creates an Uno Pipe, a TextOutputStream that writes $input to the pipe, and a TextInputStream that uses its ReadLine() method to read the frist line from that pipe. According to https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1io_1_1XTextInputStream.html#a723d8ab1b4f3966a0e95043c20d8fa71, the ReadLine() function should always right-trim all line-ending charactes (\r and/or \n) from the string it returns. However, that is not always the case: input = "abc" & chr(13) 'ends in \r ret = ReadLine(input) 'ret has length 4 - ERROR input = "abc" & chr(10) 'ends in \n ret = ReadLine(input) 'ret has length 4 - ERROR In both cases (i.e. a single line-ending character at the very end) the line-ending character will be returned as the last character of the result. input = "abc" & chr(13) & "def" 'no issue - ok input = "abc" & chr(10) & "def" 'no issue - ok input = "abc" & chr(13) & chr(10) 'no issue - ok input = "abc" & chr(13) & chr(10) & "def" 'no issue - ok In all other cases I have tried, there doesn't seem to be an issue. The workaround is obvious: Don't forget to right-trim the returned result. Steps to Reproduce: As described above and by the sample code in the attachment. Actual Results: The returned string of TextInputStream.ReadLine() may include line ending characters. Expected Results: Line ending characters should always be stripped from the returned string, as is suggested by the api documentation. Reproducible: Always User Profile Reset: No Additional Info: Tested the pre-installed version of LibreOffice: Version: 7.3.7.2 / LibreOffice Community Build ID: 30(Build:2) CPU threads: 4; OS: Linux 5.15; UI render: default; VCL: gtk3 Locale: de-DE (en_US.UTF-8); UI: en-US Ubuntu package version: 1:7.3.7-0ubuntu0.22.04.6 Calc: threaded Tested on the current "fresh" version of LibreOffice as an AppImage, just to confirm that this is still an issue: Version: 24.8.0.3 (X86_64) / LibreOffice Community Build ID: 0bdf1299c94fe897b119f97f3c613e9dca6be583 CPU threads: 4; OS: Linux 5.15; UI render: default; VCL: gtk3 Locale: de-DE (en_US.UTF-8); UI: en-US Calc: threaded Same on Windows in a virtual machine: Version: 24.2.5.2 (X86_64) / LibreOffice Community Build ID: bffef4ea93e59bebbeaf7f431bb02b1a39ee8a59 CPU threads: 2; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win Locale: de-DE (de_DE); UI: de-DE Calc: threaded
Created attachment 196120 [details] sample code to showcase the issue with TextInputStream.ReadLine()
Mike, I'm not sure what behavior should be here, any opinion?
Code pointer: OTextInputStream::implReadString in https://opengrok.libreoffice.org/xref/core/io/source/TextInputStream/TextInputStream.cxx?r=36703975#160; line 191 there is where the break happens for the EOF case, before stripping code starting at line 198 has a chance to do its job.
I provided a patch. Can anyone review it? https://gerrit.libreoffice.org/c/core/+/177393
Alin Andrei Abahnencei committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/734f80b66947210861ab2beb216e0dc327959e18 tdf#162716 Always strip line-ending characters It will be available in 25.8.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Alin Andrei Abahnencei committed a patch related to this issue. It has been pushed to "libreoffice-25-2": https://git.libreoffice.org/core/commit/7b5e52fb3fee9314833d0aee0d60f4124a98be82 tdf#162716 Always strip line-ending characters It will be available in 25.2.0.0.beta2. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.