Skip to content

Commit 2afc604

Browse files
Add marker name escaping, use v2 access-token
Update call to get access-token from v1 to v2. Pull up latest acdb submodule and add marker name html escaping capabilities for getSearchMarkers
1 parent a430fd5 commit 2afc604

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

ActiveCaptainCommunitySDK/ActiveCaptainCommunitySDK/ActiveCaptainDatabase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ typedef struct TileXY {
144144
@param maxResultCount maximum number of results to return
145145
@return Array of SearchMarkers in the given bounding box (matching name, if specified)
146146
*/
147-
- (NSArray<SearchMarker *> *)getSearchMarkersByName: (NSString *)name south:(double)south west:(double)west north:(double)north east:(double)east maxResultCount:(int)maxResultCount;
147+
- (NSArray<SearchMarker *> *)getSearchMarkersByName: (NSString *)name south:(double)south west:(double)west north:(double)north east:(double)east maxResultCount:(int)maxResultCount escapeHtml:(bool)escapeHtml;
148148
/*!
149149
@brief Set content of HTML &lt;head&gt; tag to be used in rendered HTML. If not called, default CSS will be used.
150150
@param value content of HTML &lt;head&gt; tag, including CSS style values

ActiveCaptainCommunitySDK/ActiveCaptainCommunitySDK/ActiveCaptainDatabase.mm

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#import "NavDateTimeExtensions.hpp"
2424
#import "Repository.hpp"
2525
#import "SearchMarker.h"
26+
#import "StringUtil.hpp"
2627
#import "UpdateService.hpp"
2728
#import "UTL_pub_lib_cnvt.h"
2829
#import "Version.hpp"
@@ -147,7 +148,7 @@ - (void)installTileWithPath: (NSString *)path tileX:(int) tileX tileY:(int) tile
147148
}
148149

149150
// DataService
150-
- (NSArray<SearchMarker *> *)getSearchMarkersByName: (NSString *)name south:(double)south west:(double)west north:(double)north east:(double)east maxResultCount:(int)maxResultCount {
151+
- (NSArray<SearchMarker *> *)getSearchMarkersByName: (NSString *)name south:(double)south west:(double)west north:(double)north east:(double)east maxResultCount:(int)maxResultCount escapeHtml:(bool)escapeHtml {
151152
Acdb::SearchMarkerFilter filter;
152153

153154
std::string nameStr = [self toString:name];
@@ -202,6 +203,11 @@ - (void)installTileWithPath: (NSString *)path tileX:(int) tileX tileY:(int) tile
202203

203204
NSMutableArray *results = [[NSMutableArray alloc] init];
204205
for (std::vector<Acdb::ISearchMarkerPtr>::iterator it = searchMarkers.begin(); it != searchMarkers.end(); it++) {
206+
std::string markerName = it->get()->GetName();
207+
if (escapeHtml == true) {
208+
Acdb::String::HtmlEscape(markerName);
209+
}
210+
205211
std::map<ACDB_type_type, MarkerType>::const_iterator markerTypeIt = MARKER_TYPES.find((*it)->GetType());
206212
if (markerTypeIt == MARKER_TYPES.end()) {
207213
markerTypeIt = MARKER_TYPES.begin();
@@ -214,7 +220,7 @@ - (void)installTileWithPath: (NSString *)path tileX:(int) tileX tileY:(int) tile
214220

215221
SearchMarker* result = [[SearchMarker alloc] init];
216222
result.markerId = (*it)->GetId();
217-
result.name = [self toNSString:(*it)->GetName()];
223+
result.name = [self toNSString:markerName];
218224
result.markerType = markerTypeIt->second;
219225
result.latitude = (*it)->GetPosition().lat * UTL_SEMI_TO_DEG;
220226
result.longitude = (*it)->GetPosition().lon * UTL_SEMI_TO_DEG;

ActiveCaptainSample/ActiveCaptainSample/ActiveCaptainAPIClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import PromiseKit
2121
class ActiveCaptainAPIClient {
2222
func getAccessToken(serviceUrl: String, serviceTicket: String) -> Promise<String> {
2323
var components = URLComponents(string:ActiveCaptainConfiguration.apiBaseURL)!
24-
components.path += "/api/v1/authentication/access-token"
24+
components.path += "/api/v2/authentication/access-token"
2525
components.queryItems = [URLQueryItem(name:"serviceUrl", value:serviceUrl), URLQueryItem(name:"serviceTicket", value:serviceTicket)]
2626

2727
return sendRequestAndDecode(String.self, .get, components)

ActiveCaptainSample/ActiveCaptainSample/SearchViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class SearchViewController: UITableViewController, UISearchResultsUpdating {
113113

114114
func updateSearchResults(for searchController: UISearchController) {
115115
if searchController.searchBar.text!.count > ActiveCaptainConfiguration.markerMinSearchLength {
116-
searchMarkers = ActiveCaptainManager.instance.database.getSearchMarkers(byName: searchController.searchBar.text!, south:-90.0, west:-180.0, north: 90.0, east:180.0, maxResultCount:Int32(ActiveCaptainConfiguration.markerMaxSearchResults))
116+
searchMarkers = ActiveCaptainManager.instance.database.getSearchMarkers(byName: searchController.searchBar.text!, south:-90.0, west:-180.0, north: 90.0, east:180.0, maxResultCount:Int32(ActiveCaptainConfiguration.markerMaxSearchResults), escapeHtml:false)
117117
}
118118

119119
self.tableView.reloadData()

0 commit comments

Comments
 (0)