Improve api version code validation (#1303)

### Describe what your pull request does and which issue you’re targeting
This PR improves the validation of the version code received from the api.
Closes #1287
<br><br>

<!-- Make sure you are targeting the "main" branch, pull requests on release branches are only allowed for bug fixes. -->

- [x] I carefully read the [contribution guidelines](https://codeberg.org/GitNex/GitNex/src/branch/main/CONTRIBUTING.md).
- [x] I'm following the code standards as defined [here](https://codeberg.org/gitnex/GitNex/wiki/Code-Standards).
- [x] By submitting this pull request, I permit GitNex to license my work under
  the [GNU General Public License v3](https://codeberg.org/GitNex/GitNex/src/branch/main/LICENSE).

Co-authored-by: DrMaxNix <git@drmaxnix.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1303
Reviewed-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: DrMaxNix <mail@drmaxnix.de>
Co-committed-by: DrMaxNix <mail@drmaxnix.de>
This commit is contained in:
DrMaxNix 2023-09-24 11:38:23 +00:00 committed by M M Arif
parent 27d1433cc1
commit 163b780f0b

View File

@ -36,7 +36,7 @@ public class Version {
return false; return false;
} }
final Pattern patternValid = final Pattern patternValid =
Pattern.compile("^[v,V]?(\\d+)+(\\.(\\d+))*([_,\\-,+][\\w,\\d,_,\\-,+]*)?$"); Pattern.compile("^[vV]?(\\d+)+(\\.(\\d+))*([_\\-+][\\w\\-+\\.]*)?$");
return value.equals("main") || patternValid.matcher(value).find(); return value.equals("main") || patternValid.matcher(value).find();
} }