Skip to content

Commit 4fabf3c

Browse files
committed
Merge pull request #156 from pe4cey/remove-enterprise-check-for-remote-guides
Respect whitelisted remote guides hosts from server regardless of ser…
2 parents 0daf172 + a0ca798 commit 4fabf3c

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

app/scripts/init/commandInterpreters.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ angular.module('neo4jApp')
142142
is_remote = yes
143143
url = input[('play'.length+2)..]
144144
host = url.match(/^(https?:\/\/[^\/]+)/)[1]
145-
host_ok = Utils.hostIsAllowed host, $rootScope.kernel['browser.remote_content_hostname_whitelist'], $rootScope.neo4j.enterpriseEdition
145+
host_ok = Utils.hostIsAllowed host, $rootScope.kernel['browser.remote_content_hostname_whitelist']
146146
else
147147
topic = topicalize(clean_url) or 'start'
148148
url = "content/guides/#{topic}.html"

lib/helpers.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ class neo.helpers
142142
@stripNGAttributes = (string = '') ->
143143
string.replace(/(\s+(ng|data|x)[^\s=]*\s*=\s*("[^"]*"|'[^']*'|[\w\-.:]+\s*))/ig, '')
144144

145-
@hostIsAllowed = (hostname, whitelist, is_enterprise) ->
146-
return true if is_enterprise and (not whitelist or whitelist is '*')
147-
whitelisted_hosts = if is_enterprise then whitelist.split(",") else ['http://guides.neo4j.com', 'https://guides.neo4j.com', 'http://localhost', 'https://localhost']
148-
hostname in whitelisted_hosts
145+
@hostIsAllowed = (hostname, whitelist) ->
146+
return true if whitelist is '*'
147+
whitelisted_hosts = if whitelist? and whitelist isnt '' then whitelist.split(",") else ['http://guides.neo4j.com', 'https://guides.neo4j.com', 'http://localhost', 'https://localhost']
148+
hostname in whitelisted_hosts
149149

150150
@getBrowserName = ->
151151
return 'Opera' if !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0

test/spec/other/utils.coffee

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,16 @@ describe 'Utils', () ->
118118
text = 'hello<script>alert(1)</script> <p onclick="alert(1)" ng-show=\'false\'>xxx</p>'
119119
expect(Utils.cleanHTML text).toBe 'hello <p>xxx</p>'
120120

121-
it 'should respect whitelist for enterprise edition', ->
121+
it 'should respect whitelist from server', ->
122122
host = 'http://first.com'
123123
whitelist = 'http://second.com,http://third.com'
124-
expect(Utils.hostIsAllowed host, '*', yes).toBe yes
125-
expect(Utils.hostIsAllowed host, host, yes).toBe yes
126-
expect(Utils.hostIsAllowed host, whitelist, yes).toBe no
127-
128-
it 'should ignore whitelist for non enterprise editions', ->
129-
host = 'http://first.com'
130-
whitelist = 'http://second.com,http://third.com'
131-
expect(Utils.hostIsAllowed host, '*', no).toBe no
132-
expect(Utils.hostIsAllowed host, host, no).toBe no
133-
expect(Utils.hostIsAllowed host, whitelist, no).toBe no
134-
expect(Utils.hostIsAllowed 'http://guides.neo4j.com', whitelist, no).toBe yes
124+
expect(Utils.hostIsAllowed host, '*').toBe yes
125+
expect(Utils.hostIsAllowed host, null).toBe no
126+
expect(Utils.hostIsAllowed host, '').toBe no
127+
expect(Utils.hostIsAllowed host, host).toBe yes
128+
expect(Utils.hostIsAllowed host, whitelist).toBe no
129+
expect(Utils.hostIsAllowed 'http://guides.neo4j.com', null).toBe yes
130+
expect(Utils.hostIsAllowed 'http://guides.neo4j.com', '').toBe yes
135131

136132
it 'should merge two arrays with documents without duplicates', ->
137133
arr1 = [getDocument('MATCH (n) RETURN n'), getDocument('//My script\nRETURN "me"')]

0 commit comments

Comments
 (0)