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

DAV client: Check if array itself has property in for loop #31

Merged
merged 1 commit into from
Sep 13, 2017

Conversation

leonklingele-work
Copy link

This prevents looping through properties of the array's prototype

@leonklingele-work
Copy link
Author

@PVince81 @evert ptal

@PVince81
Copy link
Contributor

PVince81 commented Sep 9, 2017

@leonklingele-work did you test this with IE11 ? Would be good to also test with latest Safari, etc to make sure they all work properly with this method call.

@leonklingele-work
Copy link
Author

@PVince81 no, but it should be supported by every browser. Even IE6 supports it and it has been in the standards since.

Steps to reproduce the issue I have:

  1. Make sure this patch is not applied
  2. Go to your 'Personal Settings'
  3. Open the developer console an paste this (extends all arrays with a new diff method):
Array.prototype.diff = function(a) {
	return this.filter(function(i) {
		return a.indexOf(i) < 0;
	});
};
  1. Try to change your profile picture by opening the file picker to select a file
  2. File picker doesn't open, Uncaught TypeError: propertyName.match is not a function [..]

@PVince81
Copy link
Contributor

@leonklingele-work can you test it at least with IE11 then ? That's the one browser I usually don't trust much with "shoulds" 😉

https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/

@PVince81
Copy link
Contributor

Raised owncloud/core#28971 to upgrade the lib in ownCloud once this PR is merged. I wasn't aware that it would break OC features. Thanks.

This prevents looping through properties of the array's prototype
@leonklingele-work
Copy link
Author

The fix works fine in Safari 10 and IE11.
I have updated this PR to run the check in ever for .. in properties loop (we have two such loops).
Please take another look.

@PVince81
Copy link
Contributor

Now thinking of it, would you mind adding a unit test for this ?

Let me know if you need help.

I suggest simply adding a global beforeEach on which you add a custom property on the Array, and then remove it again in afterEach. This would run all possible tests with the extra property and confirm that your fix helps. (try running without your fix to confirm that the problem is detected)

@leonklingele-work
Copy link
Author

leonklingele-work commented Sep 12, 2017

Sorry — unit tests are unrelated to this change. They should be provided in a separate PR.

@PVince81
Copy link
Contributor

unit tests are unrelated to this change

In general every PR should come with unit tests to validate that the change that was made is covered by tests. If you don't want to write unit tests I'm fine doing this myself, just let me know.

@PVince81
Copy link
Contributor

As discussed on IRC, I'll take care of this. Thanks!

@PVince81 PVince81 merged commit 0f416a8 into owncloud:master Sep 13, 2017
@PVince81
Copy link
Contributor

pushed here: b375917

I verified that the test actually works by commenting out the changes in this PR, and the tests indeed failed.

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.

2 participants