-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix ids of permission checkboxes for shares #9237
Merged
MorrisJobke
merged 2 commits into
master
from
fix-ids-of-permission-checkboxes-for-shares
Apr 19, 2018
Merged
Fix ids of permission checkboxes for shares #9237
MorrisJobke
merged 2 commits into
master
from
fix-ids-of-permission-checkboxes-for-shares
Apr 19, 2018
Conversation
This file contains 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
The ids of permission checkboxes for shares were generated using the "shareWith" field of the share. The "shareWith" field can contain spaces (as spaces are allowed, for example, in user or circle names), so this could cause the id attribute of the HTML element to contain spaces too, which is forbidden by the HTML specification. It is not just a "formal" issue, though; when the list was rendered, if the id contained a space the selector to get the checkbox element was wrong (as it ended being something like "#canEdit-view1-name with spaces") and thus the initial state of the checkbox was not properly set. Besides that, "shareWith" can contain too single quotes, which would even cause the jQuery selector to abort the search and leave the UI in an invalid state. Instead of adding more cases to the regular expression to escape special characters and apply it too when the ids are created now the ids of permission checkboxes for shares are based on the "shareId" field instead of on "shareWith", as "shareId" is expected to always contain compatible characters. Signed-off-by: Daniel Calviño Sánchez <[email protected]>
The escaping of special characters was needed when the ids of the permission checkboxes for shares were based on the "shareWith" field. Since they are based on the "shareId" field the escaping is no longer needed, as the "sharedId" is expected to always contain compatible characters. Signed-off-by: Daniel Calviño Sánchez <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #9237 +/- ##
============================================
- Coverage 51.91% 51.91% -0.01%
Complexity 25361 25361
============================================
Files 1606 1606
Lines 95311 95309 -2
Branches 1394 1394
============================================
- Hits 49478 49475 -3
- Misses 45833 45834 +1
|
rullzer
approved these changes
Apr 18, 2018
if the share id is unique to different recipients of the same share, go for it |
MorrisJobke
approved these changes
Apr 19, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested an works 👍
🏓 regarding the backport 😉 |
Backport is in #9453 ;-) |
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.
The ids of permission checkboxes for shares were generated using the
shareWith
field of the share. TheshareWith
field can contain spaces (as spaces are allowed, for example, in user or circle names), so this could cause the id attribute of the HTML element to contain spaces too, which is forbidden by the HTML specification.It is not just a formal issue, though; when the list was rendered, if the id contained a space the selector to get the checkbox element was wrong (as it ended being something like
#canEdit-view1-name with spaces
, which was therefore seen as the element of typespaces
that is a descendant of the element of typewith
that is in turn descendant of the element with idcanEdit-view1-name
) and thus the initial state of the checkbox was not properly set; see first test case below.Besides that,
shareWith
can contain too single quotes, which would even cause the jQuery selector to abort the search and leave the UI in an invalid state; see second test case below.Instead of adding more cases to the regular expression to escape special characters and apply it too when the ids are created now the ids of permission checkboxes for shares are based on the
shareId
field instead of onshareWith
, asshareId
is expected to always contain compatible characters; due to that it is no longer needed to escape the special characters.How to test (1)
user name with spaces
Expected result:
The file is shared and the Can edit checkbox is checked; it is possible to check and uncheck it.
Actual result:
The file is shared but the Can edit checkbox is not checked, and it is not possible to check and uncheck it.
How to test (2)
user'
Expected result:
The file is shared and you can keep adding other shares.
Actual result:
The file is shared but the input field to search for other sharees is kept disabled. Reloading the page and opening the Sharing tab again does not even show the input field.