Glossary Transformation feature is case sensitive

Hi!

https://extensions.xwiki.org/xwiki/bin/view/Extension/Glossary%20Application/#HGlossaryTransformationinaction

It’s works only when both words (in the Glossary and in the text) have the same case (upper- or lower-).
Tell me please how to fix it?

Thanks.

Hi. You can find the sources here: GitHub - xwiki-contrib/application-glossary: Glossary Application

You can send Pull Requests and we will apply them if they’re good. We can also help you if you have specific questions ofc!

Also you can raise jira issues (and check existing ones) a Loading...

Note that this app is not supported by the XWiki dev team. It was developed and is supported by its author. You can see that info on the extension page at https://extensions.xwiki.org/xwiki/bin/view/Extension/Glossary%20Application/ in the “Developed by” field.

Thx!

1 Like

I already created issue, but I wonder if I can solve the problem alone in case of a long reaction from the author :slight_smile:

Indeed the reaction could be very long since I don’t think the author is active on it (haven’t seen him for lots of months now) :slight_smile:

Exactly :slight_smile:
I saw his activity, so I doubted …

Sad, but no success… :frowning:
Got stuck on VS Code Test running attempt:

Project build error: Non-resolvable parent POM for org.xwiki.contrib.glossary:application-glossary:0.3-SNAPSHOT:
Failure to transfer org.xwiki.contrib:parent-platform:pom:8.4-8
from Central Repository: was cached in the local repository,
resolution will not be reattempted until the update interval of central has elapsed or updates are forced.
Original error: Could not transfer artifact org.xwiki.contrib:parent-platform:pom:8.4-8 from/to central (Central Repository:):
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target and ‘parent.relativePath’ points at wrong local POM

One observation: comparison between source
and

DocumentResourceReference linkReference = new DocumentResourceReference(reference.toString());

vs

ResourceReference linkReference = new DocumentResourceReference(wordBlock.getWord());

is it correct?

Thanks.

A LinkBlock requires a ResourceReference passed to it. When rendered to HTML (for ex), the LinkBlock will generate the <A HREF="...">....</A> structure and it’ll put the content of the serialized ResourceReference in the HREF.

The code you referenced seems ok. Basically there’s a cache of document resource references (a Map), which has the key being the glossary word. For known glossary words, the code gets the corresponding document reference.

Actually I checked a bit more and the code to save a cache entry is at https://github.com/xwiki-contrib/application-glossary/blob/master/application-glossary-api/src/main/java/org/xwiki/contrib/glossary/internal/DefaultEntryRetrieval.java#L68

This code has some important limitations:

  • It forces the reference to be to the main wiki! It should use the current wiki instead
  • It doesn’t support nested pages!

And yes the check here is case sensitive: application-glossary/application-glossary-api/src/main/java/org/xwiki/contrib/glossary/internal/GlossaryTransformation.java at master · xwiki-contrib/application-glossary · GitHub

That’s what would need to be fixed.

The fix is very simple:

  1. convert the word to lowercase before getting it from the cache. String word = wordBlock.getWord();String word = wordBlock.getWord().toLowerCase();
  2. Always store words in lowercase in the cache index at https://github.com/xwiki-contrib/application-glossary/blob/master/application-glossary-api/src/main/java/org/xwiki/contrib/glossary/internal/DefaultEntryRetrieval.java#L69 (so convert to lowercase there too)