Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit fb205cb

Browse files
author
Dominik Frantisek Bucik
committed
Normalization and better search-data construction
- construct search data without using the array_merge function - normalize the query - normalize search data
1 parent b52fc8c commit fb205cb

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"ext-curl": "*",
3333
"ext-json": "*",
3434
"ext-openssl": "*",
35+
"ext-iconv": "*",
3536
"web-token/jwt-key-mgmt": "^2.2",
3637
"web-token/jwt-signature": "^2.2",
3738
"web-token/jwt-signature-algorithm-rsa": "^2.2",

lib/Disco.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace SimpleSAML\Module\perun;
44

5+
use Normalizer;
56
use SimpleSAML\Module\discopower\PowerIdPDisco;
67
use SimpleSAML\Utils\HTTP;
78
use SimpleSAML\Error\Exception;
@@ -793,13 +794,13 @@ private static function arrayFlatten($array): array
793794
if (is_array($array)) {
794795
foreach ($array as $key => $value) {
795796
if (is_array($value)) {
796-
$return = array_merge($return, self::arrayFlatten($value));
797+
$return = [ ...$return, ...self::arrayFlatten($value)];
797798
} else {
798-
$return[$key] = $value;
799+
$return = [ ...$return, $value];
799800
}
800801
}
801802
} else {
802-
$return = [ $array ];
803+
$return = [$array];
803804
}
804805
return $return;
805806
}
@@ -817,11 +818,11 @@ private static function constructSearchData($idpMetadata): string
817818

818819
foreach ($keys as $key) {
819820
if (!empty($idpMetadata[$key])) {
820-
$dataSearchKeys = arra($dataSearchKeys, self::arrayFlatten($idpMetadata[$key]));
821+
$dataSearchKeys = [...$dataSearchKeys, ...self::arrayFlatten($idpMetadata[$key])];
821822
}
822823
}
823824
$res .= (' ' . implode(' ', $dataSearchKeys));
824825

825-
return strtolower(str_replace('"', '', $res));
826+
return strtolower(str_replace('"', '', iconv('UTF-8', 'US-ASCII//TRANSLIT', $res)));
826827
}
827828
}

www/res/js/disco.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ $(document).ready(function() {
1111
$("#entries").show();
1212
}
1313

14+
$("#showEntries").click(function() {
15+
$("#last-used-idp-wrap").hide();
16+
$("#entries").show();
17+
$("#showEntries").hide();
18+
});
19+
1420
let forceShow = false
1521
$('#query').keyup(function() {
16-
const filter = $(this).val().trim().toLowerCase();
22+
const filter = $(this).val().trim().toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu, "")
1723
if (!filter) {
1824
hideAll();
1925
forceShow = false;

0 commit comments

Comments
 (0)