Skip to content

Fix: handle resource names with special characters in admin settings#722

Open
Elabyad247 wants to merge 2 commits intomultitheftauto:masterfrom
Elabyad247:fix-721-admin-settings-resource-name-with-dash
Open

Fix: handle resource names with special characters in admin settings#722
Elabyad247 wants to merge 2 commits intomultitheftauto:masterfrom
Elabyad247:fix-721-admin-settings-resource-name-with-dash

Conversation

@Elabyad247
Copy link
Copy Markdown

Closes #721

Fix aGetResourceSettings and getResourceSettings pattern matching in admin and admin2
The previous gsub calls had two bugs:

  1. The leading '*','#','@' strip pattern was unanchored, so the character could be stripped from the middle of a name.
  2. resName was interpolated into a Lua pattern without escaping, so resources whose names contain special characters (like -) would produce wrong results.
    Anchor both patterns with '^' and escape special characters in resName.

Copy link
Copy Markdown
Contributor

@omar-o22 omar-o22 left a comment

Choose a reason for hiding this comment

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

Tested in admin works correctly, but admin2 the value is not updating, You should restart admin2 or reconnect.

@Elabyad247
Copy link
Copy Markdown
Author

It looks like a pre-existing issue in admin2 unrelated to this issue/fix. Would you prefer I dig into it in this PR, or open a separate issue for it so this one stays scoped to #721?

@omar-o22
Copy link
Copy Markdown
Contributor

It looks like a pre-existing issue in admin2 unrelated to this issue/fix. Would you prefer I dig into it in this PR, or open a separate issue for it so this one stays scoped to #721?

Umm for me idk you could ask qaisjp about that

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes admin/admin2 resource-settings parsing so resource names containing Lua pattern characters don’t break matching, and so leading access markers are only stripped at the start of the key (closing #721).

Changes:

  • Anchor the leading access-marker strip (*/#/@) to the start of the setting key.
  • Escape resName before interpolating it into Lua patterns.
  • Anchor the resName. prefix removal to the start (and end) of the string for exact matching.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
[admin]/admin2/server/admin_ACL.lua Fixes pattern matching in getResourceSettings by anchoring and escaping resName.
[admin]/admin/server/admin_settings.lua Fixes pattern matching in aGetResourceSettings by anchoring and escaping resName.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread [admin]/admin2/server/admin_ACL.lua Outdated
Comment thread [admin]/admin/server/admin_settings.lua Outdated
@qaisjp
Copy link
Copy Markdown
Member

qaisjp commented Apr 22, 2026

Once you address the inefficiency that copilot flagged, we're good to go

@Elabyad247
Copy link
Copy Markdown
Author

I moved safeResName and pattern outside the loop to avoid repetitive computation.

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.

get/set() doesn't update settings if resource name has '-'

4 participants