From 0abf4132eb4b2dd07ad686cb8c4224d0152a9649 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pierre-=C3=89tienne=20Lord?=
<7397743+pelord@users.noreply.github.com>
Date: Tue, 5 Dec 2017 16:03:55 -0500
Subject: [PATCH] feat(getFeatureInfo): entire content instead of only body
(#111)
* innerhtml param now allowed to keep his own style. Putting into a iframe.
* managing regex to validate empty body
* ng lint 'safe'
* Update query.service.ts
---
.../feature-details.component.html | 9 ++------
.../feature-details.component.ts | 7 ++++--
src/lib/query/shared/query.service.ts | 23 +++++++++++--------
3 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/src/lib/feature/feature-details/feature-details.component.html b/src/lib/feature/feature-details/feature-details.component.html
index d82905a6c8..2e87f06fa1 100644
--- a/src/lib/feature/feature-details/feature-details.component.html
+++ b/src/lib/feature/feature-details/feature-details.component.html
@@ -1,4 +1,4 @@
-
+
+
diff --git a/src/lib/feature/feature-details/feature-details.component.ts b/src/lib/feature/feature-details/feature-details.component.ts
index a3ab16b718..0dfebc852e 100644
--- a/src/lib/feature/feature-details/feature-details.component.ts
+++ b/src/lib/feature/feature-details/feature-details.component.ts
@@ -1,6 +1,6 @@
import { Component, Input, ChangeDetectionStrategy,
ChangeDetectorRef } from '@angular/core';
-
+import { DomSanitizer } from '@angular/platform-browser';
import { Feature } from '../shared';
@Component({
@@ -19,8 +19,11 @@ export class FeatureDetailsComponent {
}
private _feature: Feature;
- constructor(private cdRef: ChangeDetectorRef) { }
+ constructor(private cdRef: ChangeDetectorRef, private sanitizer: DomSanitizer) { }
+ isUrl(value) {
+ return this.sanitizer.bypassSecurityTrustResourceUrl(value);
+ }
isObject(value) {
return typeof value === 'object';
}
diff --git a/src/lib/query/shared/query.service.ts b/src/lib/query/shared/query.service.ts
index 4c8f949ea1..6f9bb192d8 100644
--- a/src/lib/query/shared/query.service.ts
+++ b/src/lib/query/shared/query.service.ts
@@ -149,14 +149,14 @@ export class QueryService {
const clickx1 = clickx + threshold * 2;
const clicky1 = clicky + threshold * 2;
- const wkts = 'POLYGON((' + clickx + ' ' + clicky + ', ' + clickx + ' ' + clicky1 +
+ const wkt_poly = 'POLYGON((' + clickx + ' ' + clicky + ', ' + clickx + ' ' + clicky1 +
', ' + clickx1 + ' ' + clicky1 + ', ' + clickx1 + ' ' + clicky +
', ' + clickx + ' ' + clicky + '))';
const format = new ol.format.WKT();
- const yourGeometry = format.readFeature(wkts);
- const f = (yourGeometry.getGeometry() as any);
+ const tenPercentWidthGeom = format.readFeature(wkt_poly);
+ const f = (tenPercentWidthGeom.getGeometry() as any);
let target_igo2 = '_blank';
let icon_html = 'link';
@@ -172,16 +172,19 @@ export class QueryService {
case 'innerhtml':
target_igo2 = 'innerhtml';
icon_html = 'place';
- const pos_body_debut = res['_body'].toLowerCase().indexOf('');
- const pos_body_fin = res['_body'].toLowerCase().lastIndexOf('') + 7;
- res['_body'] = res['_body'].slice(pos_body_debut, pos_body_fin);
+ const body_tag_start = res['_body'].toLowerCase().indexOf('');
+ const body_tag_end = res['_body'].toLowerCase().lastIndexOf('') + 7;
+ // replace \r \n and ' ' with '' to validate that the body is really empty.
+ if ( res['_body'].replace(/ /g, '')
+ .replace(/(?:\r\n|\r|\n)/g, '' )
+ .slice(body_tag_start, body_tag_end)
+ .replace(' ', '') === '' || res['_body'] === '' ) {
+ return [];
+ }
+ res['_body'] = res['_body'];
break;
}
- if ( res['_body'] === '') {
- return [];
- }
-
return [{
id: 'html1',