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

Sanitize URLs in file fields to handle invalid pipe characters ('|') #12156

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hitalo-siriano
Copy link

Closes #11876.

  • Introduced URLUtil.createUri() and URLUtil.create() to handle URL sanitization.
  • Replaced direct calls to URI.create() and URI.create().toURL() with the new utility methods.
  • URLs containing the pipe character ('|') are now properly encoded as '%7C' to prevent parsing errors.
  • Added test cases to URLUtilTest to verify correct sanitization and URL creation.

…loses JabRef#11876.

- Introduced URLUtil.createUri() and URLUtil.create() to handle URL sanitization.
- Replaced direct calls to URI.create() and URI.create().toURL() with the new utility methods.
- URLs containing the pipe character ('|') are now properly encoded as '%7C' to prevent parsing errors.
- Added test cases to URLUtilTest to verify correct sanitization and URL creation.
@hitalo-siriano
Copy link
Author

Am I on the right track to resolve this Issue?


public static URI createUri(String url) {
try {
String urlFormat = url.replace("|", "%7C");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining why we are doing this and the relevant references.

Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an Architecture Test disallowing the use of URI.create

try {
String urlFormat = url.replace("|", "%7C");
return new URI(urlFormat);
} catch (URISyntaxException e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @throws JavaDoc, too

@koppor
Copy link
Member

koppor commented Nov 11, 2024

@hitalo-siriano Are you still on it? The steps to finish it seem to be small.

@hitalo-siriano
Copy link
Author

@koppor Yes, I'm still working on the changes

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

Successfully merging this pull request may close these issues.

Illegal character in query: pipe character in file field
3 participants