metadata101 / iso19139.ca.HNAP

ISO Harmonized North American Profile (HNAP)
GNU General Public License v2.0
4 stars 19 forks source link

Link incorrect for license in full view. #360

Closed ianwallen closed 10 months ago

ianwallen commented 11 months ago

When going to the advanced view to view a metadata record that has a license with the following text

Open Government Licence - Canada (http://open.canada.ca/en/open-government-licence-canada) i.e.

image

It will display the following in the full view page.

image

Clicking on the link will fail because it will attempt to go to "http://open.canada.ca/en/open-government-licence-canada)" with the ")" at the end of the url and the url will fail.

To reproduce

jodygarnett commented 11 months ago

The text looks to be provided by https://github.com/metadata101/iso19139.ca.HNAP/blob/3.12.x/src/main/plugin/iso19139.ca.HNAP/inflate-metadata.xsl

                <xsl:choose>
                  <xsl:when test="$altLang = 'fra'">Open Government Licence - Canada (http://open.canada.ca/en/open-government-licence-canada)</xsl:when>
                  <xsl:otherwise>Licence du gouvernement ouvert - Canada (http://ouvert.canada.ca/fr/licence-du-gouvernement-ouvert-canada)</xsl:otherwise>
                </xsl:choose>

And whatever code recognizes http URLs is including the trailing ) producing a broken link.

josegar74 commented 11 months ago

The related code that needs to be reviewed is:

https://github.com/geonetwork/core-geonetwork/blob/4806aff89f193fd7c2a2c2bdb69fc4895c9299e1/schemas/iso19139/src/main/plugin/iso19139/formatter/xsl-view/view.xsl#L1133-L1143

ianwallen commented 11 months ago

@josegar74 If I take a sample record and set the resource constraints to text with a url. I see the following on the basic view (which seem correct)

image

But in the Full view I see the following (which is not correct)

image

So it seems like the basic view is using the regex that you highlighed but in the "full view", it seems to be using a different method to set the url. And that seems to have a bug.

jodygarnett commented 11 months ago

The quick fix would be to add spaces around the URL: Open Government Licence - Canada ( http://open.canada.ca/en/open-government-licence-canada )

ianwallen commented 11 months ago

I don't think it is that quick of a fix. 1 - submit a PR to HNAP to modify the template (optional) 2 - update our templates 3 - search and replace all existing occurrences in the metadata 4 - republish some records. And we would have to hope that nobody decides to update add another licence with a link in it.

This is currently on a licence link - I don't suspect that this is an emergency that would warrant this kind of change as I doubt it is the top link that people are trying to link to.

I would prefer to identify the root cause of the issue.

Thank you for the suggestion.

ianwallen commented 11 months ago

@josegar74 The bug seems to be with this code

https://github.com/geonetwork/core-geonetwork/blob/66a8ca819192eed8754ce77697f8847e7a9d9d86/web/src/main/webapp/xslt/common/utility-tpl.xsl#L126-L141

I think it should be modified to use a similar regular expression to the code you pointed to. Note that this code does not get applied to which I believe is why it was not the source of this bug.

https://github.com/geonetwork/core-geonetwork/blob/4806aff89f193fd7c2a2c2bdb69fc4895c9299e1/schemas/iso19139/src/main/plugin/iso19139/formatter/xsl-view/view.xsl#L1123-L1152