Skip to content

Commit

Permalink
Merge pull request #31 from blackberry-webworks/next-whitelist
Browse files Browse the repository at this point in the history
Fix for whitelist issue
  • Loading branch information
dmateescu committed Dec 12, 2011
2 parents 14e9b8c + 1dd9e83 commit 7fc7c7d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion framework/src/blackberry/web/widget/policy/WidgetPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,13 @@ public WidgetAccess getElement( String request, WidgetAccess[] accessList ) {
if ( schemeString.equals( "local" ) && folderAccess == null ) {
return _localAccess;
}

if(folderAccess != null) {
fetchedAccess = folderAccess.getWidgetAccess( requestURI.getPath() + parseNull( requestURI.getQuery() ) );
}
if( !isMatch( fetchedAccess, requestURI ) ) {
fetchedAccess = folderAccess.getWidgetAccess( requestURI.getPath() + "*" );
}

boolean failedToFindAccess = false;
// Make sure we've got the right one
Expand Down Expand Up @@ -126,6 +129,10 @@ public WidgetAccess getElement( String request, WidgetAccess[] accessList ) {
}

private boolean isMatch( WidgetAccess access, URI toMatchURI ) {
if( access == null ) {
return false;
}

// Look for local first
if( WidgetUtil.isLocalURI( toMatchURI ) && access.isLocal() ) {
// local access always allowed
Expand Down Expand Up @@ -172,6 +179,9 @@ else if( WidgetUtil.isDataURI( toMatchURI ) ) {
// 5. Compare path+query
String refPath = referenceURI.getPath() + parseNull( referenceURI.getQuery() );
String toMatchPath = toMatchURI.getPath() + parseNull( toMatchURI.getQuery() );
if( refPath.endsWith( "*" ) ) {
refPath = refPath.substring( 0, refPath.length() - 1 );
}
if( !toMatchPath.startsWith( refPath ) ) {
return false;
}
Expand Down

0 comments on commit 7fc7c7d

Please sign in to comment.