Updated site info feed and search service
Modified site info feed template to secure the description field against injected code. Also adjusted search service by extracting samples within the correct scope and including them in the returned site info. This improves the quality and security of the displayed information.
This commit is contained in:
parent
1694e9c78c
commit
5d1b7da728
@ -9,4 +9,9 @@ public record FeedItem(String title, String date, String description, String url
|
||||
return date;
|
||||
}
|
||||
|
||||
public String descriptionSafe() {
|
||||
return description
|
||||
.replace("<", "<")
|
||||
.replace(">", ">");
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,6 @@ public class SearchSiteInfoService {
|
||||
String url = "https://" + domainName + "/";;
|
||||
|
||||
var feedItemsFuture = feedlotClient.getFeedItems(domainName);
|
||||
|
||||
if (domainId < 0 || !assistantClient.isAccepting()) {
|
||||
domainInfo = createDummySiteInfo(domainName);
|
||||
similarSet = List.of();
|
||||
@ -145,12 +144,12 @@ public class SearchSiteInfoService {
|
||||
linkingDomains = assistantClient
|
||||
.linkedDomains(ctx, domainId, 100)
|
||||
.blockingFirst();
|
||||
}
|
||||
|
||||
List<UrlDetails> sampleResults = searchOperator.doSiteSearch(ctx, domainName, 1);
|
||||
List<UrlDetails> sampleResults = searchOperator.doSiteSearch(ctx, domainName, 5);
|
||||
if (!sampleResults.isEmpty()) {
|
||||
url = sampleResults.getFirst().url.withPathAndParam("/", null).toString();
|
||||
}
|
||||
}
|
||||
|
||||
FeedItems feedItems = null;
|
||||
try {
|
||||
@ -165,7 +164,8 @@ public class SearchSiteInfoService {
|
||||
domainInfo,
|
||||
similarSet,
|
||||
linkingDomains,
|
||||
feedItems
|
||||
feedItems,
|
||||
sampleResults
|
||||
);
|
||||
}
|
||||
|
||||
@ -220,7 +220,8 @@ public class SearchSiteInfoService {
|
||||
DomainInformation domainInformation,
|
||||
List<SimilarDomain> similar,
|
||||
List<SimilarDomain> linking,
|
||||
FeedItems feed
|
||||
FeedItems feed,
|
||||
List<UrlDetails> samples
|
||||
) {
|
||||
public SiteInfoWithContext(String domain,
|
||||
long domainId,
|
||||
@ -228,7 +229,8 @@ public class SearchSiteInfoService {
|
||||
DomainInformation domainInformation,
|
||||
List<SimilarDomain> similar,
|
||||
List<SimilarDomain> linking,
|
||||
FeedItems feedInfo
|
||||
FeedItems feedInfo,
|
||||
List<UrlDetails> samples
|
||||
)
|
||||
{
|
||||
this(Map.of("info", true),
|
||||
@ -239,7 +241,8 @@ public class SearchSiteInfoService {
|
||||
domainInformation,
|
||||
similar,
|
||||
linking,
|
||||
feedInfo);
|
||||
feedInfo,
|
||||
samples);
|
||||
}
|
||||
|
||||
public String getLayout() {
|
||||
|
@ -4,7 +4,17 @@
|
||||
<dl>
|
||||
{{#each items}}
|
||||
<dt><a href="{{url}}" rel="external noopener ugc">{{title}}</a></dt>
|
||||
<dd><date>{{pubDay}}</date><br>{{{description}}}</dd>
|
||||
<dd><date>{{pubDay}}</date><br>{{{descriptionSafe}}}</dd>
|
||||
{{/each}}
|
||||
</dl>
|
||||
{{/with}}
|
||||
|
||||
{{#unless feed}}{{#if samples}}
|
||||
<h2>Sample</h2>
|
||||
<dl>
|
||||
{{#each samples}}
|
||||
<dt><a href="{{url}}" rel="external noopener ugc">{{title}}</a></dt>
|
||||
<dd>{{{description}}}</dd>
|
||||
{{/each}}
|
||||
</dl>
|
||||
{{/if}}{{/unless}}
|
Loading…
Reference in New Issue
Block a user