-
-
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 |
…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. - Added @archtest to ensure that the URI.create() method is not directly called in the codebase.
* @param url the URL string to be converted into a {@link URL}. | ||
* @return the {@link URL} object created from the string URL. | ||
* @throws MalformedURLException if the URL is malformed and cannot be converted to a {@link URL}. | ||
*/ | ||
|
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.
no empty line between JavaDoc and method
add an empty line above JavaDoc
} catch ( | ||
MalformedURLException 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.
Remove empty line (we know that the IntelliJ autoformatter creates this - but no one invested significant time to fix this)
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.
Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
…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. - Added @archtest to ensure that the URI.create() method is not directly called in the codebase.
…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. - Added @archtest to ensure that the URI.create() method is not directly called in the codebase.
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.
Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
@koppor I made the requested changes, is there anything else that needs to be done? |
@hitalo-siriano please see the automated output that your code misses matching our style rules. Fix that first. That reduces load on our side. |
Closes #11876.