Bug 169884 - Links containing "~" in Markdown files may cause them to fail to open
Summary: Links containing "~" in Markdown files may cause them to fail to open
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
26.2.0.0 alpha0+ master
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:26.8.0 target:26.2.0.0.beta2
Keywords:
Depends on:
Blocks: Markdown
  Show dependency treegraph
 
Reported: 2025-12-07 21:55 UTC by nobu
Modified: 2025-12-12 15:20 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample .md file (302 bytes, text/plain)
2025-12-07 21:56 UTC, nobu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nobu 2025-12-07 21:55:15 UTC
Description:
Links containing "~" in Markdown files may cause them to fail to open.


Steps to Reproduce:
1. Create a Markdown file (.md) containing the following two URL lines:

[Selected range of Release note](https://wiki.documentfoundation.org/ReleaseNotes/26.2#Markdown:~:text=Added%20support%20for%20importing%20from%20Markdown%20format)  
https://wiki.documentfoundation.org/ReleaseNotes/26.2#Markdown:~:text=Added%20support%20for%20importing%20from%20Markdown%20format  

2. Open the file in Writer.
   Or, the following sample md file.

Actual Results:
3. Could not open Markdown file.

Expected Results:
3. You can open the file.


Reproducible: Always


User Profile Reset: No

Additional Info:

Most Markdown viewers can open this file successfully, and the links will work.

Reproducible
[2025-12-04]
Version: 26.2.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: 620(Build:0)
CPU threads: 4; OS: Windows 11 X86_64 (build 26100); UI render: Skia/Vulkan; VCL: win
Locale: en-US (ja_JP); UI: en-US
Calc: CL threaded

Reproducible
[2025-12-05]
Version: 26.2.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: 0686b1972806fe8b711de5ba64039fb38cd14889
CPU threads: 2; OS: Linux 6.1; UI render: default; VCL: gtk3
Locale: ja-JP (ja_JP.UTF-8); UI: en-US
Calc: threaded
Comment 1 nobu 2025-12-07 21:56:39 UTC
Created attachment 204491 [details]
Sample .md file
Comment 2 m_a_riosv 2025-12-08 00:01:49 UTC
Reproducible
Version: 26.2.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: 620(Build:0)
CPU threads: 16; OS: Windows 11 X86_64 (build 26200); UI render: Skia/Vulkan; VCL: win
Locale: es-ES (es_ES); UI: en-US
Calc: threaded



Latest version that works on the ones I have installed.
Version: 25.8.4.1 (X86_64)
Build ID: 6ab4ab096601e7cd763971a4dad5a6c7322a1a59
CPU threads: 16; OS: Windows 11 X86_64 (build 26200); UI render: Skia/Raster; VCL: win
Locale: en-GB (es_ES); UI: en-US
Calc: threaded
Comment 3 Saburo 2025-12-08 06:18:48 UTC
bibisected with win64-26.2
can not open 58cfa7b1a5f44b2dbd945db4fd8261b7227c33b6
can open but document is white 890d2c865215f8a679fbb8e0644e3f73c4c4bb0c

***
adding CC: Ujjawal Kumar
Please, take a look?
Comment 4 Ujjawal Kumar 2025-12-08 06:33:22 UTC
Sure
Comment 5 Ujjawal Kumar 2025-12-08 10:27:47 UTC
(In reply to Saburo from comment #3)
> bibisected with win64-26.2
> can not open 58cfa7b1a5f44b2dbd945db4fd8261b7227c33b6
> can open but document is white 890d2c865215f8a679fbb8e0644e3f73c4c4bb0c
> 
> ***
> adding CC: Ujjawal Kumar
> Please, take a look?

It is most likely a parsing issue by the md4c library. It is treating the content between the ~ in line 1 and 2 as a separate span somehow and calling only the leave_span_callback twice one with link and another with strike through without calling the corresponding enter_span_callback for the strike through leading to an extra popping for the attributes vector. The same condition triggers with other span elements like */_ or **/__. The simplest solution I can propose is adding a check for the the deletion of elements in the attributes vector. I will additionally report this problem in the git repository of the library.
Comment 6 Buovjaga 2025-12-09 08:55:33 UTC
Removing keywords and will not even add implementationError as this is due to the 3rd party lib.
Comment 7 Commit Notification 2025-12-12 06:47:24 UTC
Ujjawal Kumar committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/d38e5bc4102a228d49fdfeddc1e510e9b5bdd7ed

tdf#169884 fix crash due to missing empty check before removing element

It will be available in 26.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.
Comment 8 Commit Notification 2025-12-12 10:40:17 UTC
Ujjawal Kumar committed a patch related to this issue.
It has been pushed to "libreoffice-26-2":

https://git.libreoffice.org/core/commit/0d81f98c6fac6e11225df4249685539adc4336da

tdf#169884 fix crash due to missing empty check before removing element

It will be available in 26.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.
Comment 9 Commit Notification 2025-12-12 15:20:42 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/9f629738f1fcddc5ef77b0876e8a60330c7a8cd9

tdf#169884: sw_filter_md: Add test

It will be available in 26.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.