This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | /* global oc_requesttoken, FileList, Gallery, SlideShow */ |
||
2 | (function ($, OC, OCA, oc_requesttoken) { |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
3 | "use strict"; |
||
4 | var galleryFileAction = { |
||
5 | features: [], |
||
6 | mediaTypes: {}, |
||
7 | scrollContainer: null, |
||
8 | slideShow: null, |
||
9 | |||
10 | /** |
||
11 | * Builds a URL pointing to one of the app's controllers |
||
12 | * |
||
13 | * @param {string} endPoint |
||
14 | * @param {undefined|string} path |
||
15 | * @param {Object} params |
||
16 | * |
||
17 | * @returns {string} |
||
18 | */ |
||
19 | buildGalleryUrl: function (endPoint, path, params) { |
||
20 | var extension = ''; |
||
21 | var tokenElement = $('#sharingToken'); |
||
22 | var token = (tokenElement.val()) ? tokenElement.val() : false; |
||
23 | if (token) { |
||
24 | params.token = token; |
||
25 | extension = '.public'; |
||
26 | } |
||
27 | var query = OC.buildQueryString(params); |
||
28 | return OC.generateUrl('apps/gallery/' + endPoint + extension + path, null) + '?' + |
||
29 | query; |
||
30 | }, |
||
31 | |||
32 | /** |
||
33 | * Registers a file action for each media type |
||
34 | * |
||
35 | * @param {Array} mediaTypes |
||
36 | */ |
||
37 | register: function (mediaTypes) { |
||
38 | //console.log("enabledPreviewProviders: ", mediaTypes); |
||
39 | if (mediaTypes) { |
||
40 | // Remove SVG if the user is using an insecure browser (IE8-9) |
||
41 | if (window.galleryFileAction.features.indexOf('native_svg') > -1 && !window.btoa) { |
||
42 | mediaTypes.splice(mediaTypes.indexOf('image/svg+xml'), 1); |
||
43 | } |
||
44 | galleryFileAction.mediaTypes = mediaTypes; |
||
45 | } |
||
46 | var i, mediaTypesLength = mediaTypes.length; |
||
47 | // We only want to create slideshows for supported media types |
||
48 | for (i = 0; i < mediaTypesLength; i++) { |
||
49 | // Each click handler gets the same function and images array and |
||
50 | // is responsible to load the slideshow |
||
51 | OCA.Files.fileActions.register(mediaTypes[i], 'View', OC.PERMISSION_READ, '', |
||
52 | galleryFileAction.onView); |
||
53 | OCA.Files.fileActions.setDefault(mediaTypes[i], 'View'); |
||
54 | } |
||
55 | }, |
||
56 | |||
57 | /** |
||
58 | * Prepares the features array |
||
59 | * |
||
60 | * This is duplicated from a method found in galleryconfig. It's done that way in order to |
||
61 | * avoid having to load the whole utility class in the Files app |
||
62 | * |
||
63 | * @param configFeatures |
||
64 | * @returns {Array} |
||
65 | */ |
||
66 | buildFeaturesList: function (configFeatures) { |
||
67 | var features = []; |
||
68 | var i, configFeaturesLength = configFeatures.length; |
||
69 | if (configFeaturesLength) { |
||
70 | for (i = 0; i < configFeaturesLength; i++) { |
||
71 | features.push(configFeatures[i]); |
||
72 | } |
||
73 | } |
||
74 | |||
75 | window.galleryFileAction.features = features; |
||
76 | }, |
||
77 | |||
78 | /** |
||
79 | * Builds an array containing all the images we can show in the slideshow |
||
80 | * |
||
81 | * @param {string} filename |
||
82 | * @param {Object} context |
||
83 | */ |
||
84 | onView: function (filename, context) { |
||
85 | var imageUrl, downloadUrl; |
||
86 | var fileList = context.fileList; |
||
87 | var files = fileList.files; |
||
88 | var start = 0; |
||
89 | var images = []; |
||
90 | var dir = context.dir + '/'; |
||
91 | var width = Math.ceil(screen.width * window.devicePixelRatio); |
||
92 | var height = Math.ceil(screen.height * window.devicePixelRatio); |
||
93 | |||
94 | /* Find value of longest edge. */ |
||
95 | var longEdge = Math.max(width, height); |
||
96 | |||
97 | /* Find the next larger image size. */ |
||
98 | if (longEdge % 100 !== 0) { |
||
99 | longEdge = ( longEdge + 100 ) - ( longEdge % 100 ); |
||
100 | } |
||
101 | |||
102 | for (var i = 0; i < files.length; i++) { |
||
103 | var file = files[i]; |
||
104 | // We only add images to the slideshow if we think we'll be able |
||
105 | // to generate previews for this media type |
||
106 | if (galleryFileAction.mediaTypes.indexOf(file.mimetype) > -1) { |
||
107 | /* jshint camelcase: false */ |
||
108 | var params = { |
||
109 | width: longEdge, |
||
110 | height: longEdge, |
||
111 | c: file.etag, |
||
112 | requesttoken: oc_requesttoken |
||
113 | }; |
||
114 | imageUrl = galleryFileAction.buildGalleryUrl('preview', '/' + file.id, params); |
||
115 | params = { |
||
116 | c: file.etag, |
||
117 | requesttoken: oc_requesttoken |
||
118 | }; |
||
119 | downloadUrl = |
||
120 | galleryFileAction.buildGalleryUrl('files', '/download/' + file.id, params); |
||
121 | |||
122 | images.push({ |
||
123 | name: file.name, |
||
124 | path: dir + file.name, |
||
125 | fileId: file.id, |
||
126 | mimeType: file.mimetype, |
||
127 | permissions: file.permissions, |
||
128 | url: imageUrl, |
||
129 | downloadUrl: downloadUrl |
||
130 | }); |
||
131 | } |
||
132 | } |
||
133 | for (i = 0; i < images.length; i++) { |
||
134 | //console.log("Images in the slideshow : ", images[i]); |
||
135 | if (images[i].name === filename) { |
||
136 | start = i; |
||
137 | } |
||
138 | } |
||
139 | |||
140 | if ($.isEmptyObject(galleryFileAction.slideShow)) { |
||
141 | galleryFileAction.slideShow = new SlideShow(); |
||
142 | $.when(galleryFileAction.slideShow.init( |
||
143 | false, |
||
144 | null, |
||
145 | window.galleryFileAction.features |
||
146 | )).then(function () { |
||
147 | // Don't show the download button on the "Files" slideshow |
||
148 | galleryFileAction.slideShow.removeButton('.downloadImage'); |
||
149 | galleryFileAction._startSlideshow(images, start); |
||
150 | }); |
||
151 | } else { |
||
152 | galleryFileAction._startSlideshow(images, start); |
||
153 | } |
||
154 | }, |
||
155 | |||
156 | /** |
||
157 | * Launches the slideshow |
||
158 | * |
||
159 | * @param {{name:string, url: string, path: string, fallBack: string}[]} images |
||
160 | * @param {number} start |
||
161 | * @private |
||
162 | */ |
||
163 | _startSlideshow: function (images, start) { |
||
164 | galleryFileAction.slideShow.setImages(images, false); |
||
165 | |||
166 | var scrollTop = galleryFileAction.scrollContainer.scrollTop(); |
||
167 | // This is only called when the slideshow is stopped |
||
168 | galleryFileAction.slideShow.onStop = function () { |
||
169 | FileList.$fileList.one('updated', function () { |
||
170 | galleryFileAction.scrollContainer.scrollTop(scrollTop); |
||
171 | }); |
||
172 | }; |
||
173 | |||
174 | // Only modern browsers can manipulate history |
||
175 | if (history && history.replaceState) { |
||
176 | // This stores the fileslist in the history state |
||
177 | var stateData = { |
||
178 | dir: FileList.getCurrentDirectory() |
||
179 | }; |
||
180 | history.replaceState(stateData, document.title, window.location); |
||
181 | |||
182 | // This creates a new entry in history for the slideshow. It will |
||
183 | // be updated as the user navigates from picture to picture |
||
184 | history.pushState(null, '', '#loading'); |
||
185 | } |
||
186 | |||
187 | galleryFileAction.slideShow.show(start); |
||
188 | } |
||
189 | }; |
||
190 | |||
191 | window.galleryFileAction = galleryFileAction; |
||
192 | })(jQuery, OC, OCA, oc_requesttoken); |
||
0 ignored issues
–
show
|
|||
193 | |||
194 | $(document).ready(function () { |
||
195 | "use strict"; |
||
196 | // Deactivates fileaction on public preview page |
||
197 | if ($('#imgframe').length > 0) { |
||
198 | return true; |
||
199 | } |
||
200 | |||
201 | if ($('html').is('.ie8')) { |
||
202 | return true; //deactivate in IE8 |
||
203 | } |
||
204 | |||
205 | window.galleryFileAction.scrollContainer = $('#app-content'); |
||
206 | if ($('#isPublic').val()) { |
||
207 | window.galleryFileAction.scrollContainer = $(window); |
||
208 | } |
||
209 | |||
210 | var utility = new Gallery.Utility(); |
||
211 | utility.addDomPurifyHooks(); |
||
212 | |||
213 | // Retrieve the config as well as the list of supported media types. |
||
214 | // The list of media files is retrieved when the user clicks on a row |
||
215 | var url = window.galleryFileAction.buildGalleryUrl('config', '', {extramediatypes: 1}); |
||
216 | $.getJSON(url).then(function (config) { |
||
217 | window.galleryFileAction.buildFeaturesList(config.features); |
||
218 | window.galleryFileAction.register(config.mediatypes); |
||
219 | }); |
||
220 | }); |
||
221 |