-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
base: main
Are you sure you want to change the base?
Conversation
…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.
Am I on the right track to resolve this Issue? |
|
||
public static URI createUri(String url) { | ||
try { | ||
String urlFormat = url.replace("|", "%7C"); |
There was a problem hiding this comment.
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.
There was a problem hiding this 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add @throws
JavaDoc, too
@hitalo-siriano Are you still on it? The steps to finish it seem to be small. |
@koppor Yes, I'm still working on the changes |
Closes #11876.