HyperlinkAddress is not correct when unicode characters are found in the link path

Hello dear Aspose team,

We are facing an issue where Aspose.Note does not return the correct hyperlink address for hyperlinks which contain Unicode characters in their address. For those hyperlinks, it simply returns the hyperlink text as hyperlink address, which is not correct.

We have created a sample project to demonstrate this behavior. Please notice that for all the hyperlinks the hyperlink text is being retrieved correctly except the ones which contain Unicode characters.

https://files.axiomint.com/external/file/4ppre888fb7ba258942afbed826d4825e3f49

If you will have difficulties downloading the project, you can simply download the sample file (the forum does not allow attaching files of .one format) and run the following code

public static void Main(string[] args)
{
    string filePath = @"Test File\OneNoteTest.one";
    using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
    {
        Document doc = new Document(fileStream);
        foreach (var page in doc)
        {
            IList<RichText> richTexts = page.GetChildNodes<RichText>();
            foreach (RichText richText in richTexts)
            {
                foreach (TextRun textRun in richText.TextRuns)
                {
                    var textStyle = textRun.Style;
                    if (textStyle.IsHyperlink && !string.IsNullOrWhiteSpace(textStyle.HyperlinkAddress))
                    {
                        string linkPath = textStyle.HyperlinkAddress;
                        string linkText = textRun.Text;

                        Console.WriteLine($"Link Text: {linkText}");
                        Console.WriteLine($"Link Path: {linkPath}");
                        Console.WriteLine("-----------------------");
                        Console.WriteLine();
                    }
                }
            }
        }
    }

    Console.ReadKey();
}

Sample file:

Link 1: OneNoteTest.one
Link 2: OneNoteTest.one - Google Drive

@vahem,

Thanks for the sample document and details.

After an initial testing, I was able to reproduce the issue as you mentioned by using your sample document. I found HyperlinkAddress is not correctly retrieved when unicode characters are found in the link path of the document.

We require thorough evaluation of the issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): NOTENET-5832

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The issues you have found earlier (filed as NOTENET-5832) have been fixed in this update. This message was posted using Bugs notification tool by senua.remizova

1 Like

@amjad.sahi Unfortunately, the new update broke the old functionality we were relying on. It seems to us that all the links are getting trimmed now after the first “#” character, which causes us to not see all the information coming after this character (section-id, base-path, etc.).
This can be clearly be visible with the test application that we provided as part of this support ticket

Results previously (everything is being reported correctly except the unicode link path)

Link Text: Rename
Link Path: onenote:Rename.one#section-id={90E2A70A-EF2A-44A7-ACB3-3BDF5FD82FF3}&end&base-path=D:\OneNote%20Test
-----------------------

Link Text: Rename2
Link Path: onenote:#section-id={90E2A70A-EF2A-44A7-ACB3-3BDF5FD82FF3}&end&base-path=D:\OneNote%20Test\Rename.one
-----------------------

Link Text: Rename4
Link Path: onenote:Rename.one#base-path=D:\OneNote%20Test
-----------------------

Link Text: Rename5
Link Path: onenote:Rename.one#base-path=D:\OneNote%20Test
-----------------------

Link Text: ChildRename2
Link Path: onenote:Rename.one#section-id={D6FAB630-417A-4E4A-9AA3-9651D07A68E7}&end&base-path=D:\OneNote%20Test\Child
-----------------------

Link Text: AmpersandRename
Link Path: onenote:AAA%20&%20BBB\Rename.one#section-id={A7855CCF-6EB9-4C6C-858B-FA3383E07E58}&end&base-path=D:\OneNote%20Test
-----------------------

Link Text: UnicodeRename1
Link Path: UnicodeRename1
-----------------------

Results in the Aspose.Notes 24.7 version (all the link paths are being reported incorrectly)

Link Text: Rename
Link Path: onenote:Rename.one
-----------------------

Link Text: Rename2
Link Path: onenote:
-----------------------

Link Text: Rename4
Link Path: onenote:Rename.one
-----------------------

Link Text: Rename5
Link Path: onenote:Rename.one
-----------------------

Link Text: ChildRename2
Link Path: onenote:Rename.one
-----------------------

Link Text: AmpersandRename
Link Path: onenote:AAA%20&%20BBB\Rename.one
-----------------------

Link Text: UnicodeRename1
Link Path: onenote:
-----------------------

Is there anything we are missing?

@vahem,

I did test your scenario/case using Aspose.Note for .NET 24.7 with your original OneNote document. You are right as I found all the links are getting trimmed now after the first “#” character. We have reopened your ticket “NOTENET-5832”. We will look into it to figure it out soon.

1 Like

@vahem,

We would appreciate it if you could provide us with your expected results. What specific results are you looking to achieve using the Aspose.Note for .NET library? Once we have this information, we will be able to evaluate and incorporate any necessary enhancements to meet your needs.

@amjad.sahi We just want to get full hyperlink paths and link texts as they can be seen in the OneNote hyperlink editor itself.
This means that whatever format is used for the hyperlink there, the same we want to get in the result window. This means that all the results from the Aspose.Note version 24.6 (and prior versions) were expected and correct

E.g.

onenote:AAA%20&%20BBB\Rename.one#section-id={A7855CCF-6EB9-4C6C-858B-FA3383E07E58}&end&base-path=D:\OneNote%20Test
onenote:#section-id={90E2A70A-EF2A-44A7-ACB3-3BDF5FD82FF3}&end&base-path=D:\OneNote%20Test\Rename.one
onenote:Rename.one#section-id={90E2A70A-EF2A-44A7-ACB3-3BDF5FD82FF3}&end&base-path=D:\OneNote%20Test

The only issue that we had with Aspose.Note was that it was not giving us those hyperlink paths when it contained URL characters.

2 example URLs that we used in our sample files were

onenote:⺀⺁⺂⺃¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹ÊËÌÍΑβγδεζηθικדהוזח؉؊ٓ٧٩\Rename.one#section-id={D6EDA46C-2E76-4515-A1D6-56A057019647}&end&base-path=D:\OneNote%20Test
onenote:Rename.one#section-id={D6EDA46C-2E76-4515-A1D6-56A057019647}&end&base-path=D:\OneNote%20Test\⺀⺁⺂⺃¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹ÊËÌÍΑβγδεζηθικדהוזח؉؊ٓ٧٩

We would like to be able to receive those kind of hyperlink paths the same way as they are being shown in the Microsoft OneNote’s “Edit Link” window.

P.S. Our product helps users to modify hyperlinks in various Microsoft Office filetypes. In order to accomplish the task for links containing unicode characters we first need to receive the hyperlink path as is (regardless of the characters used in the hyperlink path).

@vahem,

Thank you for providing details on your expected/desired results. I have logged the details with your existing ticket “NOTENET-5832” into our database. We will be looking into it soon.
Once we have an update, we will let you know here.

Once we have an update on it, we will let you know here.

1 Like

@vahem,

We have further evaluated your requirements (expected results) and are pleased to inform you that our upcoming version (Aspose.Note for .NET 24.8) will include the fix/enhancement for your desired output. The next version is due in the second half of August next month.

1 Like

@amjad.sahi Thank you very much!

@vahem,

You are welcome.

@vahem,

Please try Aspose.Note for .NET v24.8, which includes the fix/enhancement for your requirements.

Please let us know if the issue persists.

1 Like

@amjad.sahi We’ve checked the fix and we are quite happy with the fix. The unicode link path is now getting reported correctly along with all the other regular link paths.

The only issue that we have is with the link text. The link/anchor text is correct for all the links except the links which contain unicode characters. The sample file that we provided contained 2 links containing unicode characters - named “UnicodeRename1” and “UnicodeRename2” accordingly.

Here are the results that we see for those links

  1. LinkPath=[onenote:⺀⺁⺂⺃¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹ÊËÌÍΑβγδεζηθικדהוזח؉؊ٓ٧٩\Rename.one#section-id={D6EDA46C-2E76-4515-A1D6-56A057019647}&end&base-path=D:\OneNote%20Test]
    LinkText=[﷟HYPERLINK "onenote:⺀⺁⺂⺃¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹ÊËÌÍΑβγδεζηθικדהוזח؉؊ٓ٧٩\Rename.one#section-id={D6EDA46C-2E76-4515-A1D6-56A057019647}&end&base-path=D:\OneNote%20Test"UnicodeRename1]
  2. LinkPath=[onenote:Rename.one#section-id={D6EDA46C-2E76-4515-A1D6-56A057019647}&end&base-path=D:\OneNote%20Test\⺀⺁⺂⺃¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹ÊËÌÍΑβγδεζηθικדהוזח؉؊ٓ٧٩]
    LinkText=[﷟HYPERLINK "onenote:Rename.one#section-id={D6EDA46C-2E76-4515-A1D6-56A057019647}&end&base-path=D:\OneNote%20Test\⺀⺁⺂⺃¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹ÊËÌÍΑβγδεζηθικדהוזח؉؊ٓ٧٩"UnicodeRename2]

The expected results here are

  1. LinkPath=[onenote:⺀⺁⺂⺃¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹ÊËÌÍΑβγδεζηθικדהוזח؉؊ٓ٧٩\Rename.one#section-id={D6EDA46C-2E76-4515-A1D6-56A057019647}&end&base-path=D:\OneNote%20Test]
    LinkText=[UnicodeRename1]
  2. LinkPath=[onenote:Rename.one#section-id={D6EDA46C-2E76-4515-A1D6-56A057019647}&end&base-path=D:\OneNote%20Test\⺀⺁⺂⺃¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹ÊËÌÍΑβγδεζηθικדהוזח؉؊ٓ٧٩]
    LinkText=[UnicodeRename2]

If we can get this fixed too, we will be quite happy :slight_smile:

@vahem,

Thanks for the details.

It is nice to know that the latest version fixes the issue for HyperlinkAddress when unicode characters are found in the link path. We will evaluate and try to fix the issue where link/anchor text not correct for unicode characters as per your needs. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): NOTENET-5846

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like