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

Allow for spaces between quotes in nodes #104

Open
realcallum opened this issue Nov 24, 2019 · 9 comments
Open

Allow for spaces between quotes in nodes #104

realcallum opened this issue Nov 24, 2019 · 9 comments
Labels
bug Confirmed issues with the application help wanted A good issue to start contributing

Comments

@realcallum
Copy link

When trying to add prefixes to already created ranks on the LuckPerms editor, it doesn't allow spaces.
Not sure if there is anyway you can fix this, as it sets anything after a space as another permission.

Maybe you could add a separate option for prefixes, or maybe allow " ".

@Turbotailz
Copy link
Member

Is this for the new version of the editor? I need to figure out a good way to handle this.

@realcallum
Copy link
Author

Is this for the new version of the editor? I need to figure out a good way to handle this.

Yes.

@lucko lucko transferred this issue from LuckPerms/LuckPerms Nov 29, 2019
@Turbotailz Turbotailz changed the title LuckPerms Editor - Setting prefixes [v2] Allow for spaces between quotes in nodes Dec 1, 2019
@Turbotailz Turbotailz added the bug Confirmed issues with the application label Dec 1, 2019
@Turbotailz Turbotailz changed the title [v2] Allow for spaces between quotes in nodes Allow for spaces between quotes in nodes Jan 21, 2020
@Turbotailz Turbotailz added the help wanted A good issue to start contributing label Jan 21, 2020
@Turbotailz
Copy link
Member

For anyone who wants to help with this (I am not an expert in regex):

Currently when entering new permissions, this regex is used to check for multiple permissions being added - /,\s*|,|\s+|\s*-{1}\s+/

This works perfectly for any cases where there are multiple permissions separated by space, or multiple spaces and hyphens (as if it were copied from a yaml file). The regex needs to also check for quotes " " and make sure the quotes are kept intact, no matter how many spaces are added inside of them.

Here's an example on regexr: https://regexr.com/4smc5
Basically it needs to keep the same behaviour but not split the permission with quotes.

Hoping that someone will have a solution for this :)

@Andre601
Copy link
Contributor

Maybe only split on comma (similar to how tags on various sites work)?

@Turbotailz
Copy link
Member

But then users can't paste multiple permissions from various sources. It is almost always spaces, or spaces with hyphens.

@BrainStone
Copy link
Contributor

BrainStone commented Jan 21, 2020

\s*(?:,|-)?\s+

That alone is an improvement. Working on one that handles those cases properly.

@BrainStone
Copy link
Contributor

After a bit of discussion the question came up as to why you don't just split at the newline?
That leaves no room for speculation where the nodes are separated.

And to trim them, always trim the left side and if it's then not a prefix or suffix node, also trim the right side.

@Turbotailz
Copy link
Member

Because new lines aren't supported in a text input, they are converted to spaces.

I feel like it should be a requirement that prefixes/suffixes which include spaces should be wrapped in quotes.

@RealTrashPanda
Copy link

I did some searching and found \s+(?=([^"]*"[^"]*")*[^"]*$) https://regexr.com/54d2o

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed issues with the application help wanted A good issue to start contributing
Projects
None yet
Development

No branches or pull requests

5 participants