Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Homepage url validation for extension listing #12389

Merged
merged 6 commits into from
May 13, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/extensibility/ExtensionManagerView.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50, regexp: true */
/*global define, $, brackets */
/*global define, $, brackets, Mustache, PathUtils */
/*unittests: ExtensionManager*/

define(function (require, exports, module) {
Expand All @@ -35,6 +35,7 @@ define(function (require, exports, module) {
registry_utils = require("extensibility/registry_utils"),
InstallExtensionDialog = require("extensibility/InstallExtensionDialog"),
LocalizationUtils = require("utils/LocalizationUtils"),
LanguageManager = require("language/LanguageManager"),
itemTemplate = require("text!htmlContent/extension-manager-view-item.html"),
Mustache = require("thirdparty/mustache/mustache");

Expand Down Expand Up @@ -337,6 +338,25 @@ define(function (require, exports, module) {
context[helper] = registry_utils[helper];
});

// Do some extra validation on homepage url to make sure we don't end up executing local binary
if (context.metadata.homepage) {
var parsed = PathUtils.parseUrl(context.metadata.homepage);

// We can't rely on path-utils because of known problems with protocol identification
// Falling back to Browsers protocol identification mechanism
var tmpLink = document.createElement('a');
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to create an 'a' element everytime. You can resuse it? The GC of V8 is memory hungry, so will never know when this will be GC'ed.

tmpLink.href = context.metadata.homepage;

// Check if the homepage refers to a local resource
if (tmpLink.protocol === "file:") {
var language = LanguageManager.getLanguageForExtension(parsed.filenameExtension.replace(/^\./, ''));
// If identified language for the local resource is binary, don't list it
if (language && language.isBinary()) {
delete context.metadata.homepage;
}
}
}

return $(this._itemTemplate(context));
};

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/nls/bg/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -783,4 +783,4 @@ define({
"DESCRIPTION_INDENT_LINE_COMMENT" : "Задайте true за включване на отстъпа на коментарите за ред"
});

/* Last translated for a505026d40a4eb0bffc196eda30557c0e6b021bc */
/* Last translated for a505026d40a4eb0bffc196eda30557c0e6b021bc */