Links in SharePoint Online's web view are broken in Aspose.Words 22.2 and other versions

When we were trying to investigate an issue for one of our clients we found out that links in SharePoint Online’s web view are broken in Aspose.Words 22.2 and other versions.

We specifically don’t know which version of Aspose.Words DLL introduced this issue, but when we tested the following versions listed below, all of them were resulting in the same bug. Where there is an addition of \h\l or \l to the link.

Aspose.Words versions tested:

  • Aspose.Words 22.3
  • Aspose.Words 22.2
  • Aspose.Words 22.1
  • Aspose.Words 21.10
  • Aspose.Words 21.5
  • Aspose.Words 21.1
  • Aspose.Words 20.5
    We also tested the latest version of Aspose.Words 22.4 and found out that the issue was not reproduced, however, the Aspose release notes for this version of Aspose.Words don’t mention anything about this fix.

We want to understand what the issue was and how it got solved. We also want to make sure that this was not fixed unknowingly and it did not introduce other issues in Aspose.Words 22.4 and the issue will not come back in future releases.

We have tried to create a simple console application to reproduce the issue with Aspose.Words 22.2.

  • It contains “Doc1.docx“ document in “Word File“ folder which contains a link to “https://linktek.sharepoint.com/sites/Raghu/Shared Documents/Vahe - Test/Modify Links Test/Glossary.pdf”.
  • Since it would be difficult to create a console application which would interact with SPO (we would need to implement whole CSOM API there) and considering the fact that the issue can be partially reproduced with running Aspose.Words DLL methods on local files and then uploading them to SPO, we decided to run the application on the local file from the previous step.
  • The program loads the file, gets the hyperlink, changes it to “https://linktek.sharepoint.com/sites/Raghu/Shared Documents/Vahe - Test/Moved Test/Glossary.pdf” and saves the file back to “\AsposeWordCorruption\bin\Debug\Word File\Doc1 AFTER.docx“ output file.

Interestingly, our console application is able to reproduce the issue only with licensed version of Aspose.Words. With trial version the link looks and works okay after uploading file to SharePoint Online. Screenshots have been attached below.

unlicensed version.png (77.8 KB)
licensed version.png (17.3 KB)

The console application can be accessed from this link: https://files.axiomint.com/external/folder/6xnob45d68379c5d8424e95bed05974ea80e3

@vikram.venugopal This is not an accidental fix. The issue was fixed with WORDSNET-23465. MS Word has a tricky logic when writes hyperlink tag if there is a bookmark start/end right before the hyperlink field parent paragraph. Now Aspose.Words mimics MS Word behavior.
In your case, in earlier version the hyperlink was written as

<w:r>
	<w:fldChar w:fldCharType="begin" />
</w:r>
<w:r>
	<w:instrText xml:space="preserve"> HYPERLINK </w:instrText>
</w:r>
<w:r>
	<w:instrText>"https://linktek.sharepoint.com/sites/Raghu/Shared Documents/Vahe - Test/Moved Test/Glossary.pdf"</w:instrText>
</w:r>
<w:r>
	<w:instrText xml:space="preserve"> </w:instrText>
</w:r>
<w:r>
	<w:instrText xml:space="preserve"> </w:instrText>
</w:r>
<w:r>
	<w:instrText>\l</w:instrText>
</w:r>
<w:r>
	<w:instrText xml:space="preserve"> </w:instrText>
</w:r>
<w:r>
	<w:instrText>""</w:instrText>
</w:r>
<w:r>
	<w:fldChar w:fldCharType="separate" />
</w:r>
<w:r w:rsidRPr="00A76C35">
	<w:rPr>
		<w:rStyle w:val="Hyperlink" />
	</w:rPr>
	<w:t>Test Link</w:t>
</w:r>
<w:r>
	<w:fldChar w:fldCharType="end" />
</w:r>

Now, Aspose.Words writes it as

<w:hyperlink r:id="rId4" w:history="1">
	<w:r w:rsidRPr="00A76C35">
		<w:rPr>
			<w:rStyle w:val="Hyperlink" />
		</w:rPr>
		<w:t>Test Link</w:t>
	</w:r>
</w:hyperlink>

This behavior is expected and we have an appropriate test in our codebase.

1 Like

Thanks for the quick response Alexey.

1 Like