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

feat: add detection for more model errors #485

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

HashCookie
Copy link
Contributor

@casbin-bot
Copy link
Member

@nodece @Shivansh-yadav13 please review

const key = line.substring(0, equalIndex);
const value = line.substring(equalIndex + 1);
this.addConfig(section, key.trim(), value.trim());
const key = line.substring(0, equalIndex).trim();
Copy link
Member

Choose a reason for hiding this comment

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

Extract all grammar checking code into a "validator"


// Verify operator in matcher
public static validateMatcherOperators(value: string): void {
const invalidOperators = /(?<![&|])&(?!&)|(?![&|])\|(?!\|)|&{3,}|\|{3,}/g;

Choose a reason for hiding this comment

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

This function is using same RegExp as validateMatcher, without any reference but just as a copy - that potentially could cause a mistake in future (when RegExp will be changed in one place, but not both).

Also this kind of RegExp (especialy LookBehind) has limited support on a not so old browsers like iOS 16 (<16.4), that could lead developers to patching casbin to use with such browsers.

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.

4 participants