Skip to content

Commit 6b25792

Browse files
author
agustin
committed
Update dist after merges
1 parent e8b7538 commit 6b25792

File tree

2 files changed

+68
-20
lines changed

2 files changed

+68
-20
lines changed

dist/scripts/api-console.js

Lines changed: 66 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,21 +1162,25 @@
11621162
$scope.vm.loaded = false;
11631163
$scope.vm.error = void(0);
11641164

1165-
return ramlParser.loadPath($window.resolveUrl(url), null, $scope.options)
1166-
.then(function (raml) {
1167-
$scope.vm.raml = raml;
1168-
})
1169-
.catch(function (error) {
1170-
$scope.vm.error = angular.extend(error, {
1171-
/*jshint camelcase: false */
1172-
buffer: (error.context_mark || error.problem_mark).buffer
1173-
/*jshint camelcase: true */
1174-
});
1175-
})
1176-
.finally(function () {
1177-
$scope.vm.loaded = true;
1178-
})
1179-
;
1165+
if(RAML.LoaderUtils.ramlOriginValidate(url, $scope.options)) {
1166+
$scope.vm.error = {buffer : 'RAML origin check failed. Raml does not reside underneath the path:' + RAML.LoaderUtils.allowedRamlOrigin($scope.options)};
1167+
} else {
1168+
return ramlParser.loadPath($window.resolveUrl(url), null, $scope.options)
1169+
.then(function (raml) {
1170+
$scope.vm.raml = raml;
1171+
})
1172+
.catch(function (error) {
1173+
$scope.vm.error = angular.extend(error, {
1174+
/*jshint camelcase: false */
1175+
buffer: (error.context_mark || error.problem_mark).buffer
1176+
/*jshint camelcase: true */
1177+
});
1178+
})
1179+
.finally(function () {
1180+
$scope.vm.loaded = true;
1181+
})
1182+
;
1183+
}
11801184
}
11811185
})
11821186
;
@@ -1596,7 +1600,10 @@
15961600
restrict: 'E',
15971601
templateUrl: 'directives/raml-initializer.tpl.html',
15981602
replace: true,
1599-
controller: 'RamlInitializerController'
1603+
controller: 'RamlInitializerController',
1604+
scope: {
1605+
options: '='
1606+
}
16001607
};
16011608
})
16021609
.controller('RamlInitializerController', ['$scope', '$window', 'ramlParser', function RamlInitializerController(
@@ -1633,7 +1640,13 @@
16331640

16341641
function loadFromUrl(url) {
16351642
$scope.vm.ramlUrl = url;
1636-
return loadFromPromise(ramlParser.loadPath($window.resolveUrl(url)), {isLoadingFromUrl: true});
1643+
1644+
if(RAML.LoaderUtils.ramlOriginValidate(url, $scope.options)) {
1645+
$scope.vm.isLoadedFromUrl = true;
1646+
$scope.vm.error = {message : 'RAML origin check failed. Raml does not reside underneath the path:' + RAML.LoaderUtils.allowedRamlOrigin($scope.options)};
1647+
} else {
1648+
return loadFromPromise(ramlParser.loadPath($window.resolveUrl(url)), {isLoadingFromUrl: true});
1649+
}
16371650
}
16381651

16391652
function loadFromString(string) {
@@ -1775,7 +1788,7 @@
17751788
};
17761789

17771790
$scope.getDocumentationContent = function (content, selected) {
1778-
var lines = content.split('\n');
1791+
var lines = content.split(/\r|\n/);
17791792
var index = lines.indexOf(selected);
17801793
var result = [];
17811794
var regex = /(^#|^##)+\s(.*)$/gim;
@@ -4517,6 +4530,41 @@ RAML.Inspector = (function() {
45174530
});
45184531
})();
45194532

4533+
(function() {
4534+
'use strict';
4535+
4536+
RAML.LoaderUtils = {
4537+
4538+
allowedRamlOrigin : function(options) {
4539+
var basepath='../';
4540+
if(typeof options.ramlOriginCheck === 'string') {
4541+
basepath = options.ramlOriginCheck;
4542+
}
4543+
return basepath;
4544+
},
4545+
4546+
// prevent loading stuff from other hosts and/or services
4547+
ramlOriginValidate: function (url, options) {
4548+
var absolutePath = function(href) {
4549+
var link = document.createElement('a');
4550+
link.href = href;
4551+
return link.href;
4552+
};
4553+
4554+
var isSameBasePath = function(href, basepath) {
4555+
var absoluteBasepath=absolutePath(basepath);
4556+
var absoluteRamlPath=absolutePath(href);
4557+
return absoluteRamlPath.indexOf(absoluteBasepath, 0) === 0;
4558+
};
4559+
4560+
var decodedRamlUrl=decodeURIComponent(url);
4561+
return options && options.ramlOriginCheck && !isSameBasePath(decodedRamlUrl, RAML.LoaderUtils.allowedRamlOrigin(options));
4562+
}
4563+
4564+
4565+
};
4566+
})();
4567+
45204568
(function() {
45214569
'use strict';
45224570

dist/styles/api-console-light-theme.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,15 +501,15 @@ span.CodeMirror-selectedtext { background: none; }
501501
font-family: 'Lato';
502502
font-style: italic;
503503
font-weight: 100;
504-
src: local('Lato Hairline Italic'), local('Lato-HairlineItalic'), url(../fonts/Lato-Hairline-Italic.woff2) format('woff2');
504+
src: local('Lato Hairline Italic'), local('Lato-HairlineItalic'), url(../fonts/Lato-HairlineItalic.woff2) format('woff2');
505505
unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
506506
}
507507
/* latin */
508508
@font-face {
509509
font-family: 'Lato';
510510
font-style: italic;
511511
font-weight: 100;
512-
src: local('Lato Hairline Italic'), local('Lato-HairlineItalic'), url(../fonts/Lato-Hairline-Italic2.woff2) format('woff2');
512+
src: local('Lato Hairline Italic'), local('Lato-HairlineItalic'), url(../fonts/Lato-HairlineItalic2.woff2) format('woff2');
513513
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
514514
}
515515
/* latin-ext */

0 commit comments

Comments
 (0)