diff --git a/gradle/changelog/search_url_encoding.yaml b/gradle/changelog/search_url_encoding.yaml
new file mode 100644
index 0000000000..ef8927fde0
--- /dev/null
+++ b/gradle/changelog/search_url_encoding.yaml
@@ -0,0 +1,2 @@
+- type: fixed
+ description: Encoding in global search ([#2116](https://github.com/scm-manager/scm-manager/pull/2116))
diff --git a/scm-ui/ui-api/src/help/search/syntax.de.ts b/scm-ui/ui-api/src/help/search/syntax.de.ts
index 792d734c5f..84815ac4b0 100644
--- a/scm-ui/ui-api/src/help/search/syntax.de.ts
+++ b/scm-ui/ui-api/src/help/search/syntax.de.ts
@@ -87,34 +87,13 @@ Standardmäßig werden Repository-Namen um 1,5 und Namespace-Namen um 1,25 geboo
Hinweis: Logische Operatoren müssen in Großbuchstaben eingegeben werden (z. B. „AND").
-
-
- | Definition |
- Beispiel |
-
-
- | AND – beide Terme müssen enthalten sein |
- Ultimate AND Repository – findet z.B. Ultimate Repository, Ultimate Special Repository
- |
-
-
- | OR – mindestens einer der Terme muss enthalten sein |
- Ultimate OR Repository – findet z.B.. Ultimate Repository, Ultimate User, Special Repository |
-
-
- | NOT – der nachfolgende Term darf nicht enthalten sein. „!" kann alternativ verwendet werden. |
- Ultimate NOT Repository – findet z.B.. Ultimate user, nicht jedoch z.B. Ultimate Repository |
-
-
- | – schließt den folgenden Term von der Suche aus |
- Ultimate Repository -Special – findet z.B. Ultimate Repository, schließt z.B. Ultimate Special Repository aus |
-
-
- | – der folgende Term muss enthalten sein |
- Ultimate +Repository – findet z.B. my Repository, Ultimate Repository |
-
-
-
+|Operator|Definition|Beispiel|
+|--|--|--|
+|AND|Beide Terme müssen enthalten sein|Ultimate AND Repository – findet z.B. Ultimate Repository, Ultimate Special Repository|
+|OR|Mindestens einer der Terme muss enthalten sein|Ultimate OR Repository – findet z.B.. Ultimate Repository, Ultimate User, Special Repository|
+|NOT|Der nachfolgende Term darf nicht enthalten sein, „!" kann alternativ verwendet werden|Ultimate NOT Repository – findet z.B.. Ultimate user, nicht jedoch z.B. Ultimate Repository|
+|–|Schließt den folgenden Term von der Suche aus|Ultimate Repository -Special – findet z.B. Ultimate Repository, schließt z.B. Ultimate Special Repository aus|
+|+ |Der folgende Term muss enthalten sein|Ultimate +Repository – findet z.B. my Repository, Ultimate Repository|
## Gruppieren
diff --git a/scm-ui/ui-api/src/help/search/syntax.en.ts b/scm-ui/ui-api/src/help/search/syntax.en.ts
index 099d0d22aa..dde31a6b95 100644
--- a/scm-ui/ui-api/src/help/search/syntax.en.ts
+++ b/scm-ui/ui-api/src/help/search/syntax.en.ts
@@ -87,33 +87,13 @@ By default Repository names are boosted by 1.5, namespace by 1.25.
Note: Logical Operators must be entered in upper case (e.g. "AND").
-
-
- | Definition |
- Example |
-
-
- | AND – both terms must be included |
- Ultimate AND Repository – finds e.g. Ultimate Repository, Ultimate Special Repository |
-
-
- | OR – at least one of the terms must be included |
- Ultimate OR Repository – finds e.g. Ultimate Repository, Ultimate User, Special Repository |
-
-
- | NOT – following term may not be included, "!" may be used alternatively |
- Ultimate NOT Repository – finds e.g. Ultimate user, excludes e.g. Ultimate Repository |
-
-
- | – excludes following term from search |
- Ultimate Repository -Special – finds e.g. Ultimate Repository, excludes e.g. Ultimate Special Repository |
-
-
- | – following term must be included |
- Ultimate +Repository – finds e.g. my Repository, Ultimate Repository |
-
-
-
+|Operator |Definition|Example|
+|------------|--|--|
+|AND|Both terms must be included|\`Ultimate AND Repository\` – finds e.g. Ultimate Repository, Ultimate Special Repository|
+|OR |At least one of the terms must be included|Ultimate OR Repository – finds e.g. Ultimate Repository, Ultimate User, Special Repository|
+|NOT |Following term may not be included, "!" may be used alternatively|Ultimate NOT Repository – finds e.g. Ultimate user, excludes e.g. Ultimate Repository|
+|– |Excludes following term from search|Ultimate Repository -Special – finds e.g. Ultimate Repository, excludes e.g. Ultimate Special Repository|
+|+ |Following term must be included|Ultimate +Repository – finds e.g. my Repository, Ultimate Repository|
## Grouping
diff --git a/scm-ui/ui-api/src/urls.test.ts b/scm-ui/ui-api/src/urls.test.ts
index 6300cdcde4..9fc043f8bf 100644
--- a/scm-ui/ui-api/src/urls.test.ts
+++ b/scm-ui/ui-api/src/urls.test.ts
@@ -98,6 +98,16 @@ describe("tests for getQueryStringFromLocation", () => {
expect(getQueryStringFromLocation(location)).toBe("abc");
});
+ it("should return the query string with a space instead of a plus symbol", () => {
+ const location = createLocation("?q=+(Test)");
+ expect(getQueryStringFromLocation(location)).toBe(" (Test)");
+ });
+
+ it("should return the query string with a plus symbol", () => {
+ const location = createLocation("?q=%2B(Test)");
+ expect(getQueryStringFromLocation(location)).toBe("+(Test)");
+ });
+
it("should return query string from multiple parameters", () => {
const location = createLocation("?x=a&y=b&q=abc&z=c");
expect(getQueryStringFromLocation(location)).toBe("abc");
diff --git a/scm-ui/ui-webapp/src/containers/OmniSearch.tsx b/scm-ui/ui-webapp/src/containers/OmniSearch.tsx
index a3e505ed63..af87545f8c 100644
--- a/scm-ui/ui-webapp/src/containers/OmniSearch.tsx
+++ b/scm-ui/ui-webapp/src/containers/OmniSearch.tsx
@@ -366,7 +366,9 @@ const OmniSearch: FC = () => {
selected={newEntries.length === index}
clear={clearQuery}
label={t("search.quickSearch.searchRepo")}
- link={`/search/${searchTypes[0]}/?q=${query}&namespace=${context.namespace}&name=${context.name}`}
+ link={`/search/${searchTypes[0]}/?q=${encodeURIComponent(query)}&namespace=${context.namespace}&name=${
+ context.name
+ }`}
/>
);
}
@@ -377,7 +379,7 @@ const OmniSearch: FC = () => {
selected={newEntries.length === index}
clear={clearQuery}
label={t("search.quickSearch.searchNamespace")}
- link={`/search/repository/?q=${query}&namespace=${context.namespace}`}
+ link={`/search/repository/?q=${encodeURIComponent(query)}&namespace=${context.namespace}`}
/>
);
}
@@ -387,7 +389,7 @@ const OmniSearch: FC = () => {
selected={newEntries.length === index}
clear={clearQuery}
label={t("search.quickSearch.searchEverywhere")}
- link={`/search/repository/?q=${query}`}
+ link={`/search/repository/?q=${encodeURIComponent(query)}`}
/>
);
const length = newEntries.length;
@@ -406,7 +408,7 @@ const OmniSearch: FC = () => {
return newEntries;
}, [clearQuery, context.name, context.namespace, hits, id, index, query, searchTypes, t]);
- const defaultLink = `/search/${searchType}/?q=${query}`;
+ const defaultLink = `/search/${searchType}/?q=${encodeURIComponent(query)}`;
const { onKeyDown } = useKeyBoardNavigation(entries, clearQuery, hideResults, index, setIndex, defaultLink);
return (
diff --git a/scm-ui/ui-webapp/src/search/Search.tsx b/scm-ui/ui-webapp/src/search/Search.tsx
index 4a611543a2..90c65d57e7 100644
--- a/scm-ui/ui-webapp/src/search/Search.tsx
+++ b/scm-ui/ui-webapp/src/search/Search.tsx
@@ -172,7 +172,9 @@ const Search: FC = () => {
...searchCounts,
};
- const contextQuery = `${query}${namespace ? "&namespace=" + namespace : ""}${name ? "&name=" + name : ""}`;
+ const contextQuery = `${encodeURIComponent(query)}${namespace ? "&namespace=" + namespace : ""}${
+ name ? "&name=" + name : ""
+ }`;
return (