Skip to content

Commit e9617d1

Browse files
Release new version (#221)
2 parents ea41f84 + cf62581 commit e9617d1

File tree

4 files changed

+28
-8
lines changed

4 files changed

+28
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<p align='right'>A <a href="https://developer.post.ch/">swisspost</a> project <a href="https://developer.post.ch/" border=0><img align="top" src='https://avatars.githubusercontent.com/u/92710854?s=32&v=4'></a></p>
22
<p align="center">
33
<img src="https://cloud.githubusercontent.com/assets/692124/21751899/37cc152c-d5cf-11e6-97ac-a5811f48c070.png"/>
4-
</p>
4+
</p>
55

66
# Apikana
77

npm-shrinkwrap.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apikana",
3-
"version": "0.11.0",
3+
"version": "0.11.1",
44
"description": "Integrated tools for REST API design - アピ",
55
"main": "index.js",
66
"bin": {

src/deps/helper.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@ $ = function (f) {
2929

3030
Handlebars.templates.signature = Handlebars.compile('{{sanitize signature}}');
3131

32-
var url = "../model/openapi/api.yaml";
33-
if(window.location.search !="?url="+url) {
34-
window.location.search = "?url="+url;
35-
}
32+
var url = new URL(window.location).searchParams.get('url')
33+
3634
if (!url) {
3735
alert('Please specify the API to display using the "url" query parameter.\nE.g. ' + location.origin + location.pathname + '?url=/src/openapi/api.yaml');
3836
return;
3937
}
38+
39+
var fallbackUrl = "../model/openapi/api.yaml";
40+
if(!isValidUrl(url)) {
41+
window.location.search = "?url="+fallbackUrl;
42+
}
43+
4044
if (!window.fetch) {
4145
alert('Please use a Browser.\nIt should at least support "fetch".');
4246
return;
@@ -112,6 +116,22 @@ $ = function (f) {
112116
)
113117
}
114118

119+
function isValidUrl(referencedUrl){
120+
// must be relative url
121+
if(!referencedUrl.startsWith('../')){
122+
return false;
123+
}
124+
// only allow referencing max two parent directories
125+
var matches = referencedUrl.match(/\.\.\//g);
126+
if(matches && matches.length > 2){
127+
return false;
128+
}
129+
130+
// additional check
131+
var referencedAbsoluteUrl = getAbsoluteUrl(referencedUrl)
132+
return new URL(referencedAbsoluteUrl).origin == new URL(location.href).origin
133+
}
134+
115135
function isLocalSchema(models, schema) {
116136
return _.any(models, function (m) {
117137
return normalize(schema.extra.filename) === normalize(m);

0 commit comments

Comments
 (0)