fix: escape literal % in DocShare folder LIKE condition - #138
Merged
Conversation
Draft Changelog EntryChangelog EntryFixed an issue where file permission queries were failing in certain system configurations. The DocShare folder permission check was using a literal percent character (%) in a database query condition, which caused errors when the query builder attempted to process parameters. The percent character is now properly escaped to prevent conflicts with the query parameter formatting system. This changelog entry was automatically generated by the Changelog Generator Action. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I ran some tests: everything works fine on version-15, but on version-16 the tests in test_file_permissions.py only pass 1/4:
Error:
The only test that passes doesn't use frappe.get_list(), but frappe.has_permission() instead (test: test_shared_user_has_read_permission_on_file)
@agritheory once mentioned that Frappe's get_list method changes between versions. Looking into it in detail:
version-15:
version-16:
Reading the error traceback:
The problem happens when
_mogrify()receives arguments together with a query where we pass a%, because it ends up doing something like:That's why the fix that works for both version-15 and version-16 is:
With this change, the tests pass on both version-15 and version-16.