mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-01 19:58:15 +00:00
Fix PHP byte validation and reenable builds (#7670)
* Fix PHP byte validation and reenable builds * Use checkout@v3 Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
14
.github/workflows/build.yml
vendored
14
.github/workflows/build.yml
vendored
@@ -423,6 +423,20 @@ jobs:
|
|||||||
working-directory: tests
|
working-directory: tests
|
||||||
run: bash GoTest.sh
|
run: bash GoTest.sh
|
||||||
|
|
||||||
|
build-php:
|
||||||
|
name: Build PHP
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: flatc
|
||||||
|
# FIXME: make test script not rely on flatc
|
||||||
|
run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON . && make -j
|
||||||
|
- name: test
|
||||||
|
working-directory: tests
|
||||||
|
run: |
|
||||||
|
php phpTest.php
|
||||||
|
sh phpUnionVectorTest.sh
|
||||||
|
|
||||||
build-swift:
|
build-swift:
|
||||||
name: Build Swift
|
name: Build Swift
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -486,7 +486,12 @@ class ByteBuffer
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static function validateValue($min, $max, $value, $type, $additional_notes = "") {
|
private static function validateValue($min, $max, $value, $type, $additional_notes = "") {
|
||||||
if(!($min <= $value && $value <= $max)) {
|
if (
|
||||||
|
!(
|
||||||
|
($type === "byte" && $min <= ord($value) && ord($value) <= $max) ||
|
||||||
|
($min <= $value && $value <= $max)
|
||||||
|
)
|
||||||
|
) {
|
||||||
throw new \InvalidArgumentException(sprintf("bad number %s for type %s.%s", $value, $type, $additional_notes));
|
throw new \InvalidArgumentException(sprintf("bad number %s for type %s.%s", $value, $type, $additional_notes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -371,21 +371,21 @@ function testByteBuffer(Assert $assert) {
|
|||||||
$buffer = "\0";
|
$buffer = "\0";
|
||||||
$uut = Google\FlatBuffers\ByteBuffer::wrap($buffer);
|
$uut = Google\FlatBuffers\ByteBuffer::wrap($buffer);
|
||||||
$assert->Throws(new OutOfRangeException(), function() use ($uut) {
|
$assert->Throws(new OutOfRangeException(), function() use ($uut) {
|
||||||
$uut->putShort(2, "\x63"); // 99
|
$uut->putShort(2, 2); // 99
|
||||||
});
|
});
|
||||||
|
|
||||||
//Test: ByteBuffer_PutShortChecksLength
|
//Test: ByteBuffer_PutShortChecksLength
|
||||||
$buffer = "\0";
|
$buffer = "\0";
|
||||||
$uut = Google\FlatBuffers\ByteBuffer::wrap($buffer);
|
$uut = Google\FlatBuffers\ByteBuffer::wrap($buffer);
|
||||||
$assert->Throws(new OutOfRangeException(), function() use ($uut) {
|
$assert->Throws(new OutOfRangeException(), function() use ($uut) {
|
||||||
$uut->putShort(0, "\x63"); // 99
|
$uut->putShort(0, 2); // 99
|
||||||
});
|
});
|
||||||
|
|
||||||
//Test: ByteBuffer_PutShortChecksLengthAndOffset
|
//Test: ByteBuffer_PutShortChecksLengthAndOffset
|
||||||
$buffer = str_repeat("\0", 2);
|
$buffer = str_repeat("\0", 2);
|
||||||
$uut = Google\FlatBuffers\ByteBuffer::wrap($buffer);
|
$uut = Google\FlatBuffers\ByteBuffer::wrap($buffer);
|
||||||
$assert->Throws(new OutOfRangeException(), function() use ($uut) {
|
$assert->Throws(new OutOfRangeException(), function() use ($uut) {
|
||||||
$uut->putShort(1, "\x63"); // 99
|
$uut->putShort(1, 2); // 99
|
||||||
});
|
});
|
||||||
|
|
||||||
//Test: ByteBuffer_PutIntPopulatesBufferCorrectly
|
//Test: ByteBuffer_PutIntPopulatesBufferCorrectly
|
||||||
@@ -625,7 +625,7 @@ class Assert {
|
|||||||
throw new \Exception("passed statement don't throw an exception.");
|
throw new \Exception("passed statement don't throw an exception.");
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if (get_class($e) != get_class($class)) {
|
if (get_class($e) != get_class($class)) {
|
||||||
throw new Exception("passed statement doesn't throw " . get_class($class) . ". throwws " . get_class($e));
|
throw new Exception("passed statement doesn't throw " . get_class($class) . ". throws " . get_class($e) . ": {$e->getMessage()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user