Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8bd14b4385 | |||
| cfb6f14c09 | |||
| 969aa684d9 | |||
| 74999e6f6b | |||
| 787468e67c |
@@ -56,6 +56,8 @@ return [
|
|||||||
// Automatically inferred from composer.json requirement for "php" of ">=8.2"
|
// Automatically inferred from composer.json requirement for "php" of ">=8.2"
|
||||||
'target_php_version' => '8.2',
|
'target_php_version' => '8.2',
|
||||||
"minimum_target_php_version" => "8.2",
|
"minimum_target_php_version" => "8.2",
|
||||||
|
// turn color on (-C)
|
||||||
|
"color_issue_messages_if_supported" => true,
|
||||||
|
|
||||||
// If enabled, missing properties will be created when
|
// If enabled, missing properties will be created when
|
||||||
// they are first seen. If false, we'll report an
|
// they are first seen. If false, we'll report an
|
||||||
|
|||||||
@@ -4,6 +4,6 @@
|
|||||||
<phar name="phpcs" version="^4.0.0" installed="4.0.1" location="./tools/phpcs" copy="false"/>
|
<phar name="phpcs" version="^4.0.0" installed="4.0.1" location="./tools/phpcs" copy="false"/>
|
||||||
<phar name="phpcbf" version="^4.0.0" installed="4.0.1" location="./tools/phpcbf" copy="false"/>
|
<phar name="phpcbf" version="^4.0.0" installed="4.0.1" location="./tools/phpcbf" copy="false"/>
|
||||||
<phar name="psalm" version="^5.15.0" installed="5.26.1" location="./tools/psalm" copy="false"/>
|
<phar name="psalm" version="^5.15.0" installed="5.26.1" location="./tools/psalm" copy="false"/>
|
||||||
<phar name="phpstan" version="^1.10.37" installed="1.12.32" location="./tools/phpstan" copy="false"/>
|
<phar name="phpstan" version="^2.0.0" installed="2.1.33" location="./tools/phpstan" copy="false"/>
|
||||||
<phar name="phan" version="^5.4.2" installed="5.5.2" location="./tools/phan" copy="false"/>
|
<phar name="phan" version="^5.4.2" installed="5.5.2" location="./tools/phan" copy="false"/>
|
||||||
</phive>
|
</phive>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
9.36.0
|
9.37.0
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
BASE_FOLDER=$(dirname "$(readlink -f "$0")")"/";
|
BASE_FOLDER=$(dirname "$(readlink -f "$0")")"/";
|
||||||
PACKAGE_DOWNLOAD="${BASE_FOLDER}package-download/";
|
PACKAGE_DOWNLOAD="${BASE_FOLDER}package-download/";
|
||||||
if [ ! -d "${PACKAGE_DOWNLOAD}" ]; then
|
if [ ! -d "${PACKAGE_DOWNLOAD}" ]; then
|
||||||
mkdir "${PACKAGE_DOWNLOAD}";
|
mkdir "${PACKAGE_DOWNLOAD}";
|
||||||
fi;
|
fi;
|
||||||
VERSION=$(git tag --list | sort -V | tail -n1 | sed -e "s/^v//");
|
VERSION=$(git tag --list | sort -V | tail -n1 | sed -e "s/^v//");
|
||||||
file_last_published="${BASE_FOLDER}last.published";
|
file_last_published="${BASE_FOLDER}last.published";
|
||||||
@@ -11,84 +11,84 @@ go_flag="$1";
|
|||||||
|
|
||||||
function gitea_publish
|
function gitea_publish
|
||||||
{
|
{
|
||||||
_GITEA_PUBLISH="${1}"
|
_GITEA_PUBLISH="${1}"
|
||||||
_GITEA_UPLOAD_FILENAME="${2}"
|
_GITEA_UPLOAD_FILENAME="${2}"
|
||||||
_GITEA_URL_DL="${3}"
|
_GITEA_URL_DL="${3}"
|
||||||
_GITEA_URL_PUSH="${4}"
|
_GITEA_URL_PUSH="${4}"
|
||||||
_GITEA_USER="${5}"
|
_GITEA_USER="${5}"
|
||||||
_GITEA_TOKEN="${6}"
|
_GITEA_TOKEN="${6}"
|
||||||
_PACKAGE_DOWNLOAD="${7}"
|
_PACKAGE_DOWNLOAD="${7}"
|
||||||
_VERSION="${8}"
|
_VERSION="${8}"
|
||||||
_file_last_published="${9}"
|
_file_last_published="${9}"
|
||||||
|
|
||||||
if [ -z "${_GITEA_PUBLISH}" ]; then
|
if [ -z "${_GITEA_PUBLISH}" ]; then
|
||||||
return
|
return
|
||||||
fi;
|
fi;
|
||||||
if [ -n "${_GITEA_UPLOAD_FILENAME}" ] &&
|
if [ -n "${_GITEA_UPLOAD_FILENAME}" ] &&
|
||||||
[ -n "${_GITEA_URL_DL}" ] && [ -n "${_GITEA_URL_PUSH}" ] &&
|
[ -n "${_GITEA_URL_DL}" ] && [ -n "${_GITEA_URL_PUSH}" ] &&
|
||||||
[ -n "${_GITEA_USER}" ] && [ -n "${_GITEA_TOKEN}" ]; then
|
[ -n "${_GITEA_USER}" ] && [ -n "${_GITEA_TOKEN}" ]; then
|
||||||
echo "> Publish ${_GITEA_UPLOAD_FILENAME} with ${_VERSION} to: ${_GITEA_URL_PUSH}";
|
echo "> Publish ${_GITEA_UPLOAD_FILENAME} with ${_VERSION} to: ${_GITEA_URL_PUSH}";
|
||||||
if [ ! -f "${_PACKAGE_DOWNLOAD}${_GITEA_UPLOAD_FILENAME}-v${_VERSION}.zip" ]; then
|
if [ ! -f "${_PACKAGE_DOWNLOAD}${_GITEA_UPLOAD_FILENAME}-v${_VERSION}.zip" ]; then
|
||||||
echo "> Download: ${_GITEA_UPLOAD_FILENAME}-v${_VERSION}.zip";
|
echo "> Download: ${_GITEA_UPLOAD_FILENAME}-v${_VERSION}.zip";
|
||||||
curl -LJO \
|
curl -LJO \
|
||||||
--output-dir "${_PACKAGE_DOWNLOAD}" \
|
--output-dir "${_PACKAGE_DOWNLOAD}" \
|
||||||
"${_GITEA_URL_DL}"/v"${_VERSION}".zip;
|
"${_GITEA_URL_DL}"/v"${_VERSION}".zip;
|
||||||
fi;
|
fi;
|
||||||
if [ ! -f "${_PACKAGE_DOWNLOAD}${_GITEA_UPLOAD_FILENAME}-v${_VERSION}.zip" ]; then
|
if [ ! -f "${_PACKAGE_DOWNLOAD}${_GITEA_UPLOAD_FILENAME}-v${_VERSION}.zip" ]; then
|
||||||
echo "[!] Package file does not exist for version: ${_VERSION}";
|
echo "[!] Package file does not exist for version: ${_VERSION}";
|
||||||
else
|
else
|
||||||
response=$(curl --user "${_GITEA_USER}":"${_GITEA_TOKEN}" \
|
response=$(curl --user "${_GITEA_USER}":"${_GITEA_TOKEN}" \
|
||||||
--upload-file "${_PACKAGE_DOWNLOAD}${_GITEA_UPLOAD_FILENAME}-v${_VERSION}.zip" \
|
--upload-file "${_PACKAGE_DOWNLOAD}${_GITEA_UPLOAD_FILENAME}-v${_VERSION}.zip" \
|
||||||
"${_GITEA_URL_PUSH}"?version="${_VERSION}");
|
"${_GITEA_URL_PUSH}"?version="${_VERSION}");
|
||||||
status=$(echo "${response}" | jq .errors[].status);
|
status=$(echo "${response}" | jq .errors[].status);
|
||||||
message=$(echo "${response}" | jq .errors[].message);
|
message=$(echo "${response}" | jq .errors[].message);
|
||||||
if [ -n "${status}" ]; then
|
if [ -n "${status}" ]; then
|
||||||
echo "[!] Error ${status}: ${message}";
|
echo "[!] Error ${status}: ${message}";
|
||||||
else
|
else
|
||||||
echo "> Publish completed";
|
echo "> Publish completed";
|
||||||
fi;
|
fi;
|
||||||
echo "${_VERSION}" > "${_file_last_published}";
|
echo "${_VERSION}" > "${_file_last_published}";
|
||||||
fi;
|
fi;
|
||||||
else
|
else
|
||||||
echo "[!] Missing either GITEA_UPLOAD_FILENAME, GITEA_URL_DL, GITEA_URL_PUSH, GITEA_USER or GITEA_TOKEN environment variable";
|
echo "[!] Missing either GITEA_UPLOAD_FILENAME, GITEA_URL_DL, GITEA_URL_PUSH, GITEA_USER or GITEA_TOKEN environment variable";
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
|
|
||||||
function gitlab_publish
|
function gitlab_publish
|
||||||
{
|
{
|
||||||
_GITLAB_PUBLISH="${1}";
|
_GITLAB_PUBLISH="${1}";
|
||||||
_GITLAB_URL="${2}";
|
_GITLAB_URL="${2}";
|
||||||
_GITLAB_DEPLOY_TOKEN="${3}";
|
_GITLAB_DEPLOY_TOKEN="${3}";
|
||||||
_PACKAGE_DOWNLOAD="${4}"
|
_PACKAGE_DOWNLOAD="${4}"
|
||||||
_VERSION="${5}"
|
_VERSION="${5}"
|
||||||
_file_last_published="${6}"
|
_file_last_published="${6}"
|
||||||
if [ -z "${GITLAB_PUBLISH}" ]; then
|
if [ -z "${_GITLAB_PUBLISH}" ]; then
|
||||||
return;
|
return;
|
||||||
fi;
|
fi;
|
||||||
if [ -n "${_GITLAB_URL}" ] && [ -n "${_GITLAB_DEPLOY_TOKEN}" ]; then
|
if [ -n "${_GITLAB_URL}" ] && [ -n "${_GITLAB_DEPLOY_TOKEN}" ]; then
|
||||||
curl --data tag=v"${_VERSION}" \
|
curl --data tag=v"${_VERSION}" \
|
||||||
--header "Deploy-Token: ${_GITLAB_DEPLOY_TOKEN}" \
|
--header "Deploy-Token: ${_GITLAB_DEPLOY_TOKEN}" \
|
||||||
"${_GITLAB_URL}";
|
"${_GITLAB_URL}";
|
||||||
curl --data branch=master \
|
curl --data branch=master \
|
||||||
--header "Deploy-Token: ${_GITLAB_DEPLOY_TOKEN}" \
|
--header "Deploy-Token: ${_GITLAB_DEPLOY_TOKEN}" \
|
||||||
"${_GITLAB_URL}";
|
"${_GITLAB_URL}";
|
||||||
echo "${_VERSION}" > "${_file_last_published}";
|
echo "${_VERSION}" > "${_file_last_published}";
|
||||||
else
|
else
|
||||||
echo "[!] Missing GITLAB_URL or GITLAB_DEPLOY_TOKEN environment variable";
|
echo "[!] Missing GITLAB_URL or GITLAB_DEPLOY_TOKEN environment variable";
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if [ -z "${VERSION}" ]; then
|
if [ -z "${VERSION}" ]; then
|
||||||
echo "[!] Version must be set in the form x.y.z without any leading characters";
|
echo "[!] Version must be set in the form x.y.z without any leading characters";
|
||||||
exit;
|
exit;
|
||||||
fi;
|
fi;
|
||||||
# compare version, if different or newer, deploy
|
# compare version, if different or newer, deploy
|
||||||
if [ -f "${file_last_published}" ]; then
|
if [ -f "${file_last_published}" ]; then
|
||||||
LAST_PUBLISHED_VERSION=$(cat "${file_last_published}");
|
LAST_PUBLISHED_VERSION=$(cat "${file_last_published}");
|
||||||
if dpkg --compare-versions "${VERSION}" le "${LAST_PUBLISHED_VERSION}"; then
|
if dpkg --compare-versions "${VERSION}" le "${LAST_PUBLISHED_VERSION}"; then
|
||||||
echo "[!] git tag version ${VERSION} is not newer than previous published version ${LAST_PUBLISHED_VERSION}";
|
echo "[!] git tag version ${VERSION} is not newer than previous published version ${LAST_PUBLISHED_VERSION}";
|
||||||
fi;
|
fi;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
# read in the .env.deploy file and we must have
|
# read in the .env.deploy file and we must have
|
||||||
@@ -105,8 +105,8 @@ fi;
|
|||||||
# GITLAB_TOKEN
|
# GITLAB_TOKEN
|
||||||
# GITLAB_URL
|
# GITLAB_URL
|
||||||
if [ ! -f "${BASE_FOLDER}.env.deploy" ]; then
|
if [ ! -f "${BASE_FOLDER}.env.deploy" ]; then
|
||||||
echo "[!] Deploy enviroment file .env.deploy is missing";
|
echo "[!] Deploy enviroment file .env.deploy is missing";
|
||||||
exit;
|
exit;
|
||||||
fi;
|
fi;
|
||||||
set -o allexport;
|
set -o allexport;
|
||||||
cd "${BASE_FOLDER}" || exit
|
cd "${BASE_FOLDER}" || exit
|
||||||
@@ -116,10 +116,10 @@ cd - >/dev/null 2>&1 || exit;
|
|||||||
set +o allexport;
|
set +o allexport;
|
||||||
|
|
||||||
if [ "${go_flag}" != "go" ]; then
|
if [ "${go_flag}" != "go" ]; then
|
||||||
echo "[!] No go flag given";
|
echo "[!] No go flag given";
|
||||||
echo "> Would publish ${VERSION}";
|
echo "> Would publish ${VERSION}";
|
||||||
echo "[END]";
|
echo "[END]";
|
||||||
exit;
|
exit;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
echo "[START]";
|
echo "[START]";
|
||||||
|
|||||||
@@ -268,6 +268,51 @@ class Strings
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Split up character ranges in format A-Z, a-z, 0-9
|
||||||
|
*
|
||||||
|
* @param string $input
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public static function parseCharacterRanges(string $input): array
|
||||||
|
{
|
||||||
|
// if not alphanumeric, throw value error
|
||||||
|
if (!preg_match("/^[A-Za-z0-9\-\s]+$/u", $input)) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
"The input string contains invalid characters, "
|
||||||
|
. "only alphanumeric, dash (-), space and 'or' are allowed: "
|
||||||
|
. $input
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Remove all spaces
|
||||||
|
$input = str_replace(' ', '', $input);
|
||||||
|
$result = [];
|
||||||
|
// Find all patterns like "A-Z" (character-dash-character)
|
||||||
|
preg_match_all('/(.)-(.)/u', $input, $matches, PREG_SET_ORDER);
|
||||||
|
foreach ($matches as $match) {
|
||||||
|
$start = $match[1];
|
||||||
|
$end = $match[2];
|
||||||
|
// Get ASCII/Unicode values
|
||||||
|
$startOrd = ord($start[0]);
|
||||||
|
$endOrd = ord($end[0]);
|
||||||
|
// make sure start is before end
|
||||||
|
if ($startOrd > $endOrd) {
|
||||||
|
[$startOrd, $endOrd] = [$endOrd, $startOrd];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate range of characters
|
||||||
|
for ($i = $startOrd; $i <= $endOrd; $i++) {
|
||||||
|
$char = chr($i);
|
||||||
|
if (!in_array($char, $result)) {
|
||||||
|
$result[] = $char;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// make the result unique
|
||||||
|
$result = array_unique($result);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a regex is valid. Does not return the detail regex parser error
|
* Check if a regex is valid. Does not return the detail regex parser error
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class RandomKey
|
|||||||
/** @var int character count in they key character range */
|
/** @var int character count in they key character range */
|
||||||
private static int $key_character_range_length = 0;
|
private static int $key_character_range_length = 0;
|
||||||
/** @var int default key lenghth */
|
/** @var int default key lenghth */
|
||||||
/** @deprecated Will be removed */
|
/** @deprecated Will be removed, as setting has moved to randomKeyGen */
|
||||||
private static int $key_length = 4;
|
private static int $key_length = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,7 +107,7 @@ class RandomKey
|
|||||||
* @param int $key_length key length
|
* @param int $key_length key length
|
||||||
* @return bool true for valid, false for invalid length
|
* @return bool true for valid, false for invalid length
|
||||||
*/
|
*/
|
||||||
private static function validateRandomKeyLenght(int $key_length): bool
|
private static function validateRandomKeyLength(int $key_length): bool
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
$key_length > 0 &&
|
$key_length > 0 &&
|
||||||
@@ -125,12 +125,12 @@ class RandomKey
|
|||||||
*
|
*
|
||||||
* @param int $key_length key length
|
* @param int $key_length key length
|
||||||
* @return bool true/false for set status
|
* @return bool true/false for set status
|
||||||
* @deprecated This function does no longer set the key length, the randomKeyGen parameter has to b used
|
* @deprecated This function does no longer set the key length, the randomKeyGen parameter has to be used
|
||||||
*/
|
*/
|
||||||
public static function setRandomKeyLength(int $key_length): bool
|
public static function setRandomKeyLength(int $key_length): bool
|
||||||
{
|
{
|
||||||
// only if valid int key with valid length
|
// only if valid int key with valid length
|
||||||
if (self::validateRandomKeyLenght($key_length) === true) {
|
if (self::validateRandomKeyLength($key_length) === true) {
|
||||||
self::$key_length = $key_length;
|
self::$key_length = $key_length;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -176,7 +176,7 @@ class RandomKey
|
|||||||
$key_character_range_length = self::getRandomKeyDataLength();
|
$key_character_range_length = self::getRandomKeyDataLength();
|
||||||
}
|
}
|
||||||
// if not valid key length, fallback to default
|
// if not valid key length, fallback to default
|
||||||
if (!self::validateRandomKeyLenght($key_length)) {
|
if (!self::validateRandomKeyLength($key_length)) {
|
||||||
$key_length = self::KEY_LENGTH_DEFAULT;
|
$key_length = self::KEY_LENGTH_DEFAULT;
|
||||||
}
|
}
|
||||||
// create random string
|
// create random string
|
||||||
|
|||||||
@@ -698,6 +698,84 @@ final class CoreLibsConvertStringsTest extends TestCase
|
|||||||
'Cannot match last preg error string'
|
'Cannot match last preg error string'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function parseCharacterRangesProvider(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'simple a-z' => [
|
||||||
|
['a-z'],
|
||||||
|
implode('', range('a', 'z')),
|
||||||
|
null,
|
||||||
|
],
|
||||||
|
'simple A-Z' => [
|
||||||
|
['A-Z'],
|
||||||
|
implode('', range('A', 'Z')),
|
||||||
|
null,
|
||||||
|
],
|
||||||
|
'simple 0-9' => [
|
||||||
|
['0-9'],
|
||||||
|
implode('', range('0', '9')),
|
||||||
|
null,
|
||||||
|
],
|
||||||
|
'mixed ranges' => [
|
||||||
|
['a-c', 'X-Z', '3-5'],
|
||||||
|
'abcXYZ345',
|
||||||
|
null,
|
||||||
|
],
|
||||||
|
'reverse ranges' => [
|
||||||
|
['z-a'],
|
||||||
|
'abcdefghijklmnopqrstuvwxyz',
|
||||||
|
null,
|
||||||
|
],
|
||||||
|
'overlapping ranges' => [
|
||||||
|
['a-f', 'd-j'],
|
||||||
|
'abcdefghij',
|
||||||
|
null,
|
||||||
|
],
|
||||||
|
'mixed valid and overlap ranges' => [
|
||||||
|
['a-f', 'z-a', '0-3'],
|
||||||
|
'abcdefghijklmnopqrstuvwxyz0123',
|
||||||
|
null,
|
||||||
|
],
|
||||||
|
'invalid ranges' => [
|
||||||
|
['a-あ', 'A-あ', '0-あ'],
|
||||||
|
'',
|
||||||
|
\InvalidArgumentException::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::parseCharacterRanges
|
||||||
|
* @dataProvider parseCharacterRangesProvider
|
||||||
|
* @testdox parseCharacterRanges $input to $expected [$_dataName]
|
||||||
|
*
|
||||||
|
* @param array $input
|
||||||
|
* @param string $expected
|
||||||
|
* @param string|null $expected_exception
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testParseCharacterRanges(
|
||||||
|
array $input,
|
||||||
|
string $expected,
|
||||||
|
?string $expected_exception
|
||||||
|
): void {
|
||||||
|
if ($expected_exception !== null) {
|
||||||
|
$this->expectException($expected_exception);
|
||||||
|
}
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
implode('', \CoreLibs\Convert\Strings::parseCharacterRanges(implode('', $input)))
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
Reference in New Issue
Block a user