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

Entry management: Make Link validation regex more permissive #42

Closed
rlrh opened this issue Mar 5, 2019 · 2 comments
Closed

Entry management: Make Link validation regex more permissive #42

rlrh opened this issue Mar 5, 2019 · 2 comments
Assignees
Labels
priority.High Must do type.Task Something that needs to be done, but not story, bug or epic.
Milestone

Comments

@rlrh
Copy link

rlrh commented Mar 5, 2019

This is the current validation regex for Link:

private static final String PATH = "[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
public static final String VALIDATION_REGEX = "^(https?|ftp|file)://" + PATH;

We can modify it to be more permissive as file: does not need double slashes.

With this change, entries in TypicalEntries can be simplified from
"file://" + MainApp.class.getResource("somefile").toExternalForm().substring(5)
to just
MainApp.class.getResource("somefile").toExternalForm().

@rlrh rlrh added the type.Task Something that needs to be done, but not story, bug or epic. label Mar 5, 2019
@rlrh rlrh added this to the v1.2 milestone Mar 5, 2019
@rlrh rlrh added the priority.High Must do label Mar 7, 2019
@rlrh rlrh changed the title Make Link validation regex more permissive Entry management: Make Link validation regex more permissive Mar 7, 2019
@epicfailname
Copy link

epicfailname commented Mar 7, 2019

public static final String VALIDATION_REGEX = "^(https?|ftp|file)://" + PATH;
to
public static final String VALIDATION_REGEX = "^(https?://|file:/(//)?)" + PATH;

@thomastanck
Copy link

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority.High Must do type.Task Something that needs to be done, but not story, bug or epic.
Projects
None yet
Development

No branches or pull requests

3 participants