Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF export - Need to normalize URL before doing a http query #145

Closed
pmauduit opened this issue Jun 16, 2020 · 0 comments
Closed

PDF export - Need to normalize URL before doing a http query #145

pmauduit opened this issue Jun 16, 2020 · 0 comments
Milestone

Comments

@pmauduit
Copy link
Member

pmauduit commented Jun 16, 2020

On a PDF export, it is sometimes necessary to includes graphics coming from the webapp, but the way the links are generated is not compatible with the filters used in the Security-proxy.

Example of URL:

https://dev.gdi-etau.telekom.de:/geonetwork/srv/../images/logos/4076b845-a70c-4264-9cad-f22164c8f678.png

Here is the code which is currently failing to retrieve the image:
https://github.com/georchestra/geonetwork/blob/georchestra-gn3.8.2/services/src/main/java/org/fao/geonet/api/records/formatters/ImageReplacedElementFactory.java#L134

  1. the port is not specified, because it was not set in the settings UI (the secured port was set though). Setting 443 in the classic port solved the extra ":". It is not necessary though, the URL is still valid, and can pass the URI.normalize() step.
  2. The Security-Proxy (via the spring-security configuration) will reject non-normalized URLs.
  3. Trying the URL using tools like cURL is transparent because it will normalize the URL before sending it. we might want to use --path-as-is to disable the behaviour:
       --path-as-is
              Tell  curl  to  not handle sequences of /../ or /./ in the given
              URL path. Normally curl will squash or merge them  according  to
              standards but with this option set you tell it not to do that.

We could use the java.net.URI class and the normalize() method before trying to fetch the URL.
Also line 132, the log level might not be very relevant, I would suggest debug instead of error.

pmauduit added a commit that referenced this issue Jun 17, 2020
See #145 for the motivation

Tests: runtime on a dev platform where the same fix has been deployed.
@fvanderbiest fvanderbiest added this to the 20.0.5 milestone Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants