From c8670ee85aa4b2e605480c1dfadc43f38a3f4f71 Mon Sep 17 00:00:00 2001 From: Seasoft Date: Thu, 16 May 2024 12:40:35 +0900 Subject: [PATCH 01/18] =?UTF-8?q?SC=5FResponse::sendRedirect()=20transacti?= =?UTF-8?q?onid=3D=20=E3=82=92=E7=94=BB=E4=B8=80=E7=9A=84=E3=81=AB?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=9B=E3=81=9A=E3=80=81=E7=B6=99=E6=89=BF?= =?UTF-8?q?=E3=81=99=E3=82=8B=20#922?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/class/SC_Response.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/data/class/SC_Response.php b/data/class/SC_Response.php index 018858e718..a77d12d952 100644 --- a/data/class/SC_Response.php +++ b/data/class/SC_Response.php @@ -226,7 +226,14 @@ public static function sendRedirect($location, $arrQueryString = array(), $inher $netUrl->addQueryString(session_name(), session_id()); } - $netUrl->addQueryString(TRANSACTION_ID_NAME, SC_Helper_Session_Ex::getToken()); + /** + * transactionid を受け取ったリクエストに関して、値を継承してリダイレクトする。 + * @see https://github.com/EC-CUBE/ec-cube2/issues/922 + */ + if (isset($_REQUEST[TRANSACTION_ID_NAME])) { + $netUrl->addQueryString(TRANSACTION_ID_NAME, $_REQUEST[TRANSACTION_ID_NAME]); + } + $url = $netUrl->getURL(); header("Location: $url"); From b13a3e211e9f60d8b177c212b2a6444bdc99188c Mon Sep 17 00:00:00 2001 From: Seasoft Date: Thu, 16 May 2024 12:54:41 +0900 Subject: [PATCH 02/18] =?UTF-8?q?SC=5FResponse::sendRedirect()=20transacti?= =?UTF-8?q?onid=3D=20=E3=82=92=E7=94=BB=E4=B8=80=E7=9A=84=E3=81=AB?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=9B=E3=81=9A=E3=80=81=E7=B6=99=E6=89=BF?= =?UTF-8?q?=E3=81=99=E3=82=8B=20#922?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit transactionid が指定されている場合、そちらを優先する。 --- data/class/SC_Response.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/class/SC_Response.php b/data/class/SC_Response.php index a77d12d952..f9890a3f88 100644 --- a/data/class/SC_Response.php +++ b/data/class/SC_Response.php @@ -230,7 +230,7 @@ public static function sendRedirect($location, $arrQueryString = array(), $inher * transactionid を受け取ったリクエストに関して、値を継承してリダイレクトする。 * @see https://github.com/EC-CUBE/ec-cube2/issues/922 */ - if (isset($_REQUEST[TRANSACTION_ID_NAME])) { + if (isset($_REQUEST[TRANSACTION_ID_NAME]) && !isset($netUrl->querystring[TRANSACTION_ID_NAME])) { $netUrl->addQueryString(TRANSACTION_ID_NAME, $_REQUEST[TRANSACTION_ID_NAME]); } From 51a23f9d196f46d3ad16f9a550675d0b294f9b12 Mon Sep 17 00:00:00 2001 From: Seasoft Date: Thu, 16 May 2024 19:41:37 +0900 Subject: [PATCH 03/18] =?UTF-8?q?SC=5FResponse::sendRedirect()=20transacti?= =?UTF-8?q?onid=3D=20=E3=82=92=E7=94=BB=E4=B8=80=E7=9A=84=E3=81=AB?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=9B=E3=81=9A=E3=80=81=E7=B6=99=E6=89=BF?= =?UTF-8?q?=E3=81=99=E3=82=8B=20#922?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHPUnit --- .../SC_Response/SC_ResponseWithHeaderTest.php | 71 +++++++++++++++++-- tests/class/fixtures/server/common.php | 2 +- .../server/sc_response_reload.expected | 2 +- .../fixtures/server/sc_response_reload.php | 7 +- .../sc_response_reload_add_transactionid.php | 11 +++ 5 files changed, 84 insertions(+), 9 deletions(-) create mode 100644 tests/class/fixtures/server/sc_response_reload_add_transactionid.php diff --git a/tests/class/SC_Response/SC_ResponseWithHeaderTest.php b/tests/class/SC_Response/SC_ResponseWithHeaderTest.php index 56299bb2d7..5b8a9fb766 100644 --- a/tests/class/SC_Response/SC_ResponseWithHeaderTest.php +++ b/tests/class/SC_Response/SC_ResponseWithHeaderTest.php @@ -27,16 +27,77 @@ public static function tearDownAfterClass() } } - public function testReload() + private function file_get_contents($url) { $context = stream_context_create( [ 'http' => [ - 'follow_location' => false - ] + 'follow_location' => 0, + ], ] ); - $actual = file_get_contents('http://127.0.0.1:8053/sc_response_reload.php', false, $context); - self::assertStringEqualsFile(__DIR__.'/'.self::FIXTURES_DIR.'/sc_response_reload.expected', $actual); + + $contents = file_get_contents($url, false, $context); + + return $contents; + } + + private function getExpectedContents($url, $additional_query_strings = '') + { + $contents = file_get_contents(__DIR__ . '/' . self::FIXTURES_DIR . '/sc_response_reload.expected'); + + $url .= ''; + + if (strlen($additional_query_strings) >= 1) { + $url .= '&' . $additional_query_strings; + } + + $contents = str_replace('{url}', $url, $contents); + + return $contents; + } + + public function testReload_transactionidが絡まない() + { + $request_url = 'http://127.0.0.1:8053/sc_response_reload.php?debug=' . urlencode('テスト'); + $expected_url = $request_url . '&redirect=1'; + $expected = $this->getExpectedContents($expected_url); + + $actual = $this->file_get_contents($request_url); + self::assertSame($expected, $actual); + } + + public function testReload_リクエストにtransactionidを含む() + { + $request_url = 'http://127.0.0.1:8053/sc_response_reload.php?debug=' . urlencode('テスト') . '&' . TRANSACTION_ID_NAME . '=on_reqest'; + $expected_url = $request_url . '&redirect=1'; + $expected = $this->getExpectedContents($expected_url); + + $actual = $this->file_get_contents($request_url); + self::assertSame($expected, $actual); + } + + public function testReload_ロジックにtransactionidを含む() + { + $request_url = 'http://127.0.0.1:8053/sc_response_reload_add_transactionid.php?debug=' . urlencode('テスト'); + $expected_url = $request_url . '&redirect=1&' . TRANSACTION_ID_NAME . '=on_logic'; + $expected = $this->getExpectedContents($expected_url); + + $actual = $this->file_get_contents($request_url); + self::assertSame($expected, $actual); + } + + public function testReload_ロジック・リクエストにtransactionidを含む() + { + $base_url = 'http://127.0.0.1:8053/sc_response_reload_add_transactionid.php?debug=' . urlencode('テスト'); + $request_url = $base_url; + $request_url .= '&' . TRANSACTION_ID_NAME . '=on_reqest'; + $expected_url = $base_url; + $expected_url .= '&' . TRANSACTION_ID_NAME . '=on_logic'; + $expected_url .= '&redirect=1'; + $expected = $this->getExpectedContents($expected_url); + + $actual = $this->file_get_contents($request_url); + self::assertSame($expected, $actual); } } diff --git a/tests/class/fixtures/server/common.php b/tests/class/fixtures/server/common.php index ca9ccba031..28d5837fd2 100644 --- a/tests/class/fixtures/server/common.php +++ b/tests/class/fixtures/server/common.php @@ -1,6 +1,6 @@ Content-Type: text/plain; charset=utf-8 - [1] => Location: http://127.0.0.1:8085/index.php?debug=%E3%83%86%E3%82%B9%E3%83%88&redirect=1&transactionid=aaaa + [1] => Location: {url} ) shutdown diff --git a/tests/class/fixtures/server/sc_response_reload.php b/tests/class/fixtures/server/sc_response_reload.php index 63e8df8511..0ed10702c6 100644 --- a/tests/class/fixtures/server/sc_response_reload.php +++ b/tests/class/fixtures/server/sc_response_reload.php @@ -2,7 +2,10 @@ require __DIR__.'/common.php'; -$_SERVER['REQUEST_URI'] = HTTPS_URL.'index.php?debug='.urlencode('テスト'); -$_SESSION[TRANSACTION_ID_NAME] = 'aaaa'; +/** + * この値は使われない。 + * @see https://github.com/EC-CUBE/ec-cube2/issues/922 + */ +$_SESSION[TRANSACTION_ID_NAME] = 'on_session'; SC_Response_Ex::reload(['redirect' => 1]); diff --git a/tests/class/fixtures/server/sc_response_reload_add_transactionid.php b/tests/class/fixtures/server/sc_response_reload_add_transactionid.php new file mode 100644 index 0000000000..1fba3ea491 --- /dev/null +++ b/tests/class/fixtures/server/sc_response_reload_add_transactionid.php @@ -0,0 +1,11 @@ + 1, TRANSACTION_ID_NAME => 'on_logic']); From 8399b9fcda8149558dea980c911a01a16d6e55f7 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Tue, 18 Jun 2024 17:41:49 +0900 Subject: [PATCH 04/18] =?UTF-8?q?Smarty::addPluginsDir=20=E3=81=AF?= =?UTF-8?q?=E9=9D=9E=E6=8E=A8=E5=A5=A8=E3=81=AA=E3=81=AE=E3=81=A7=20regist?= =?UTF-8?q?erPlugin=20=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 9 +++++++++ data/class/SC_View.php | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 20aa30ebc6..5ff65f5019 100644 --- a/composer.json +++ b/composer.json @@ -52,6 +52,15 @@ "classmap": [ "data/class", "data/class_extends" + ], + "files": [ + "data/smarty_extends/function.from_to.php", + "data/smarty_extends/function.include_php_ex.php", + "data/smarty_extends/modifier.h.php", + "data/smarty_extends/modifier.n2s.php", + "data/smarty_extends/modifier.nl2br_html.php", + "data/smarty_extends/modifier.script_escape.php", + "data/smarty_extends/modifier.u.php" ] } } diff --git a/data/class/SC_View.php b/data/class/SC_View.php index 143fc42ca4..976d780206 100644 --- a/data/class/SC_View.php +++ b/data/class/SC_View.php @@ -54,7 +54,13 @@ public function init() $this->_smarty->registerPlugin('modifier', 'sfMultiply', array('SC_Utils_Ex', 'sfMultiply')); $this->_smarty->registerPlugin('modifier', 'sfRmDupSlash', array('SC_Utils_Ex', 'sfRmDupSlash')); $this->_smarty->registerPlugin('modifier', 'sfCutString', array('SC_Utils_Ex', 'sfCutString')); - $this->_smarty->addPluginsDir(array('plugins', realpath(dirname(__FILE__)) . '/../smarty_extends')); + $this->_smarty->registerPlugin('function', 'from_to', 'smarty_function_from_to'); + $this->_smarty->registerPlugin('function', 'include_php_ex', 'smarty_function_include_php_ex'); + $this->_smarty->registerPlugin('modifier', 'h', 'smarty_modifier_h'); + $this->_smarty->registerPlugin('modifier', 'n2s', 'smarty_modifier_n2s'); + $this->_smarty->registerPlugin('modifier', 'nl2br_html', 'smarty_modifier_nl2br_html'); + $this->_smarty->registerPlugin('modifier', 'script_escape', 'smarty_modifier_script_escape'); + $this->_smarty->registerPlugin('modifier', 'u', 'smarty_modifier_u'); $this->_smarty->registerPlugin('modifier', 'sfMbConvertEncoding', array('SC_Utils_Ex', 'sfMbConvertEncoding')); $this->_smarty->registerPlugin('modifier', 'sfGetEnabled', array('SC_Utils_Ex', 'sfGetEnabled')); $this->_smarty->registerPlugin('modifier', 'sfNoImageMainList', array('SC_Utils_Ex', 'sfNoImageMainList')); From c5cc4d748d2e3018bef0709c6c59c2eeecbea5dd Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Tue, 18 Jun 2024 17:51:33 +0900 Subject: [PATCH 05/18] =?UTF-8?q?mobile=20=E3=83=86=E3=83=B3=E3=83=97?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=81=AF=E5=BB=83=E6=AD=A2=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=9F=E3=81=9F=E3=82=81=E9=9D=9E=E6=8E=A8=E5=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/smarty_extends/block.marquee.php | 1 + data/smarty_extends/modifier.numeric_emoji.php | 1 + 2 files changed, 2 insertions(+) diff --git a/data/smarty_extends/block.marquee.php b/data/smarty_extends/block.marquee.php index 1026b2e0ee..8d8e01259c 100644 --- a/data/smarty_extends/block.marquee.php +++ b/data/smarty_extends/block.marquee.php @@ -2,6 +2,7 @@ /** * marqueeタグで囲む。 * + * @deprecated mobile テンプレートは廃止されたため非推奨 * DoCoMoの携帯端末の場合はmarqueeを使用しない。 * * @return string 出力 diff --git a/data/smarty_extends/modifier.numeric_emoji.php b/data/smarty_extends/modifier.numeric_emoji.php index 2b9e18d911..cea4aec00c 100644 --- a/data/smarty_extends/modifier.numeric_emoji.php +++ b/data/smarty_extends/modifier.numeric_emoji.php @@ -2,6 +2,7 @@ /** * 数値を数字絵文字に変換する。 * + * @deprecated mobile テンプレートは廃止されたため非推奨 * 入力が0~9ではない場合、または、携帯端末からのアクセスではない場合は、 * 入力を [ と ] で囲んだ文字列を返す。 * From 1445b48feafab5c6077d36c7c140473934efcb3c Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Tue, 18 Jun 2024 17:42:13 +0900 Subject: [PATCH 06/18] Add array_key_exists to Smarty modifier --- data/class/SC_View.php | 1 + 1 file changed, 1 insertion(+) diff --git a/data/class/SC_View.php b/data/class/SC_View.php index 976d780206..01f94f7a47 100644 --- a/data/class/SC_View.php +++ b/data/class/SC_View.php @@ -69,6 +69,7 @@ public function init() $this->_smarty->registerPlugin('modifier', 'preg_quote', 'preg_quote'); $this->_smarty->registerPlugin('modifier', 'is_numeric', 'is_numeric'); $this->_smarty->registerPlugin('modifier', 'php_uname', 'php_uname'); + $this->_smarty->registerPlugin('modifier', 'array_key_exists', 'array_key_exists'); // XXX register_function で登録すると if で使用できないのではないか? $this->_smarty->registerPlugin('function','sfIsHTTPS', array('SC_Utils_Ex', 'sfIsHTTPS')); $this->_smarty->registerPlugin('function','sfSetErrorStyle', array('SC_Utils_Ex', 'sfSetErrorStyle')); From 443dd2d701b157cfd3c2669142083d35428a9ec6 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Wed, 19 Jun 2024 16:36:28 +0900 Subject: [PATCH 07/18] Fix deprecated: Using ${var} in strings is deprecated, use {$var} instead --- data/smarty_extends/modifier.script_escape.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/smarty_extends/modifier.script_escape.php b/data/smarty_extends/modifier.script_escape.php index 0e04180830..5ebedb9f48 100644 --- a/data/smarty_extends/modifier.script_escape.php +++ b/data/smarty_extends/modifier.script_escape.php @@ -34,7 +34,7 @@ function smarty_modifier_script_escape($value) $pattern .= "(\"|').*(onerror|onload|".implode("|", $escapeEvents).").*=.*(\"|').*"; // 正規表現をまとめる - $attributesPattern = "/${pattern}/i"; + $attributesPattern = "/{$pattern}/i"; // 置き換える文字列 $convert = '#script tag escaped#'; From f998023f231cdfd2baa9aec12686a16a1d46871c Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Wed, 19 Jun 2024 17:05:54 +0900 Subject: [PATCH 08/18] remove require --- tests/class/modifier/Modifier_ScriptEscapeTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/class/modifier/Modifier_ScriptEscapeTest.php b/tests/class/modifier/Modifier_ScriptEscapeTest.php index 8c92118781..232e5368ae 100644 --- a/tests/class/modifier/Modifier_ScriptEscapeTest.php +++ b/tests/class/modifier/Modifier_ScriptEscapeTest.php @@ -1,5 +1,4 @@ Date: Thu, 20 Jun 2024 13:02:23 +0900 Subject: [PATCH 09/18] Add README.md --- data/smarty_extends/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 data/smarty_extends/README.md diff --git a/data/smarty_extends/README.md b/data/smarty_extends/README.md new file mode 100644 index 0000000000..7d2a6dcaf6 --- /dev/null +++ b/data/smarty_extends/README.md @@ -0,0 +1,27 @@ +## このディレクトリのファイルは composer.json の autoload.classmap.files に登録することで利用可能です + +1. autoload.classmap.files に登録します。 + +``` json + "autoload": { + "classmap": [ + "data/class", + "data/class_extends" + ], + "files": [ + "data/smarty_extends/function.from_to.php", + "data/smarty_extends/function.include_php_ex.php", + "data/smarty_extends/modifier.h.php", + "data/smarty_extends/modifier.n2s.php", + "data/smarty_extends/modifier.nl2br_html.php", + "data/smarty_extends/modifier.script_escape.php", + "data/smarty_extends/modifier.u.php" + ] + } +``` + +2. composer dump-autoload コマンドを実行することで autoload の対象となります。 + +``` shell +composer dump-autoload +``` From 08a0014b4f39665d5f4d6577ebff68c2570a8142 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:40:32 +0000 Subject: [PATCH 10/18] Bump phpstan/phpstan from 1.11.4 to 1.11.5 Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.11.4 to 1.11.5. - [Release notes](https://github.com/phpstan/phpstan/releases) - [Changelog](https://github.com/phpstan/phpstan/blob/1.11.x/CHANGELOG.md) - [Commits](https://github.com/phpstan/phpstan/compare/1.11.4...1.11.5) --- updated-dependencies: - dependency-name: phpstan/phpstan dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index c1bdccc029..c42c455a35 100644 --- a/composer.lock +++ b/composer.lock @@ -1645,16 +1645,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.11.4", + "version": "1.11.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "9100a76ce8015b9aa7125b9171ae3a76887b6c82" + "reference": "490f0ae1c92b082f154681d7849aee776a7c1443" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9100a76ce8015b9aa7125b9171ae3a76887b6c82", - "reference": "9100a76ce8015b9aa7125b9171ae3a76887b6c82", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/490f0ae1c92b082f154681d7849aee776a7c1443", + "reference": "490f0ae1c92b082f154681d7849aee776a7c1443", "shasum": "" }, "require": { @@ -1699,7 +1699,7 @@ "type": "github" } ], - "time": "2024-06-06T12:19:22+00:00" + "time": "2024-06-17T15:10:54+00:00" }, { "name": "phpunit/php-code-coverage", From 296cb50e980aa14a1d6862b5c3f9ea1a17861b01 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:46:24 +0000 Subject: [PATCH 11/18] Bump docker/build-push-action from 5 to 6 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v5...v6) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/dockerbuild-and-push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dockerbuild-and-push.yml b/.github/workflows/dockerbuild-and-push.yml index 429c03c3c9..f2c56a83f7 100644 --- a/.github/workflows/dockerbuild-and-push.yml +++ b/.github/workflows/dockerbuild-and-push.yml @@ -70,7 +70,7 @@ jobs: type=match,prefix=${{ matrix.php }}-apache-,pattern=eccube2-weekly-(.*),group=1 - name: Build and export to Docker - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . load: true @@ -116,7 +116,7 @@ jobs: - run: git checkout composer.* ## see https://docs.github.com/ja/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#publishing-a-package-using-an-action - name: Push Docker image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 if: success() with: context: . From 000e48be75ce9ea7f3d5289bd2d7c56c8a7f23bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jul 2024 08:08:18 +0000 Subject: [PATCH 12/18] Bump symfony/polyfill-ctype from 1.29.0 to 1.30.0 Bumps [symfony/polyfill-ctype](https://github.com/symfony/polyfill-ctype) from 1.29.0 to 1.30.0. - [Commits](https://github.com/symfony/polyfill-ctype/compare/v1.29.0...v1.30.0) --- updated-dependencies: - dependency-name: symfony/polyfill-ctype dependency-type: indirect update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index c42c455a35..d482afe906 100644 --- a/composer.lock +++ b/composer.lock @@ -2449,16 +2449,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" + "reference": "0424dff1c58f028c451efff2045f5d92410bd540" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540", + "reference": "0424dff1c58f028c451efff2045f5d92410bd540", "shasum": "" }, "require": { @@ -2508,7 +2508,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0" }, "funding": [ { @@ -2524,7 +2524,7 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/yaml", From 752988c85f1ad82fba3af8b94fff5ecab798ca1c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jul 2024 08:55:04 +0000 Subject: [PATCH 13/18] Bump symfony/polyfill-mbstring from 1.29.0 to 1.30.0 Bumps [symfony/polyfill-mbstring](https://github.com/symfony/polyfill-mbstring) from 1.29.0 to 1.30.0. - [Commits](https://github.com/symfony/polyfill-mbstring/compare/v1.29.0...v1.30.0) --- updated-dependencies: - dependency-name: symfony/polyfill-mbstring dependency-type: indirect update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index d482afe906..51692dfa45 100644 --- a/composer.lock +++ b/composer.lock @@ -822,16 +822,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c", + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c", "shasum": "" }, "require": { @@ -882,7 +882,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0" }, "funding": [ { @@ -898,7 +898,7 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-06-19T12:30:46+00:00" } ], "packages-dev": [ From 4a67766f0ce7f6d66fa98c4f121752516688b4ab Mon Sep 17 00:00:00 2001 From: Seasoft Date: Mon, 8 Jul 2024 22:39:10 +0900 Subject: [PATCH 14/18] =?UTF-8?q?PHP=20Warning=20=E5=9B=9E=E9=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/class/helper/SC_Helper_Purchase.php | 35 ++++++++++--------- data/class/pages/LC_Page.php | 2 +- .../bloc/LC_Page_FrontParts_Bloc.php | 2 +- .../bloc/LC_Page_FrontParts_Bloc_Category.php | 3 -- .../LC_Page_FrontParts_Bloc_Recommend.php | 3 +- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/data/class/helper/SC_Helper_Purchase.php b/data/class/helper/SC_Helper_Purchase.php index 71c34bb509..3f58a5221b 100644 --- a/data/class/helper/SC_Helper_Purchase.php +++ b/data/class/helper/SC_Helper_Purchase.php @@ -1490,24 +1490,25 @@ public function checkDbMyPendignOrder() public function checkSessionPendingOrder() { - if (!SC_Utils_Ex::isBlank($_SESSION['order_id'])) { - $order_id = $_SESSION['order_id']; - unset($_SESSION['order_id']); - $objQuery = SC_Query_Ex::getSingletonInstance(); - $objQuery->begin(); - $arrOrder = SC_Helper_Purchase_Ex::getOrder($order_id); - if ($arrOrder['status'] == ORDER_PENDING) { - $objCartSess = new SC_CartSession_Ex(); - $cartKeys = $objCartSess->getKeys(); - if (SC_Utils_Ex::isBlank($cartKeys)) { - SC_Helper_Purchase_Ex::rollbackOrder($order_id, ORDER_CANCEL, true); - GC_Utils_Ex::gfPrintLog('order rollback.(session pending) order_id=' . $order_id); - } else { - SC_Helper_Purchase_Ex::cancelOrder($order_id, ORDER_CANCEL, true); - GC_Utils_Ex::gfPrintLog('order rollback.(session pending and set card) order_id=' . $order_id); - } + if (!isset($_SESSION['order_id'])) return; + if (SC_Utils_Ex::isBlank($_SESSION['order_id'])) return; + + $order_id = $_SESSION['order_id']; + unset($_SESSION['order_id']); + $objQuery = SC_Query_Ex::getSingletonInstance(); + $objQuery->begin(); + $arrOrder = SC_Helper_Purchase_Ex::getOrder($order_id); + if ($arrOrder['status'] == ORDER_PENDING) { + $objCartSess = new SC_CartSession_Ex(); + $cartKeys = $objCartSess->getKeys(); + if (SC_Utils_Ex::isBlank($cartKeys)) { + SC_Helper_Purchase_Ex::rollbackOrder($order_id, ORDER_CANCEL, true); + GC_Utils_Ex::gfPrintLog('order rollback.(session pending) order_id=' . $order_id); + } else { + SC_Helper_Purchase_Ex::cancelOrder($order_id, ORDER_CANCEL, true); + GC_Utils_Ex::gfPrintLog('order rollback.(session pending and set card) order_id=' . $order_id); } - $objQuery->commit(); } + $objQuery->commit(); } } diff --git a/data/class/pages/LC_Page.php b/data/class/pages/LC_Page.php index f9c2aae67f..63f3e7229e 100644 --- a/data/class/pages/LC_Page.php +++ b/data/class/pages/LC_Page.php @@ -300,7 +300,7 @@ public function init() // 開始時刻を設定する。 $this->timeStart = microtime(true); - $this->tpl_authority = $_SESSION['authority']; + $this->tpl_authority = $_SESSION['authority'] ?? null; // ディスプレイクラス生成 $this->objDisplay = new SC_Display_Ex(); diff --git a/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php b/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php index b1bfec95fe..f9fee7c6d5 100644 --- a/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php +++ b/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php @@ -46,7 +46,7 @@ public function init() // 開始時刻を設定する。 $this->timeStart = microtime(true); - $this->tpl_authority = $_SESSION['authority']; + $this->tpl_authority = $_SESSION['authority'] ?? null; // ディスプレイクラス生成 $this->objDisplay = new SC_Display_Ex(); diff --git a/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Category.php b/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Category.php index b3b9643a30..bc39580f29 100644 --- a/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Category.php +++ b/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Category.php @@ -36,8 +36,6 @@ class LC_Page_FrontParts_Bloc_Category extends LC_Page_FrontParts_Bloc_Ex public $arrCat; /** @var array */ public $arrTree; - /** @var int */ - public $root_parent_id; /** * Page を初期化する. @@ -127,7 +125,6 @@ public function lfGetCatTree($arrParentCategoryId, $count_check = false) foreach ($arrParentCategoryId as $category_id) { $arrParentID = $objCategory->getTreeTrail($category_id); $this->arrParentID = array_merge($this->arrParentID, $arrParentID); - $this->root_parent_id[] = $arrParentID[0]; } return $arrTree; diff --git a/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php b/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php index 2f74397904..3e53e7589c 100644 --- a/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php +++ b/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php @@ -63,8 +63,7 @@ public function process() public function action() { // 基本情報を渡す - $objSiteInfo = SC_Helper_DB_Ex::sfGetBasisData(); - $this->arrInfo = $objSiteInfo->data; + $this->arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); //おすすめ商品表示 $this->arrBestProducts = $this->lfGetRanking(); From 5fbce349913be3cc270f7340dd06eeb0a3a10dae Mon Sep 17 00:00:00 2001 From: Seasoft Date: Tue, 23 Jul 2024 00:13:19 +0900 Subject: [PATCH 15/18] =?UTF-8?q?PHP=20Warning=20=E5=9B=9E=E9=81=BF=20(?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E5=AF=BE=E5=BF=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/EC-CUBE/ec-cube2/pull/958/files#r1686055025 --- .../frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php b/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php index 3e53e7589c..b44d7539ff 100644 --- a/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php +++ b/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Recommend.php @@ -62,9 +62,6 @@ public function process() */ public function action() { - // 基本情報を渡す - $this->arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); - //おすすめ商品表示 $this->arrBestProducts = $this->lfGetRanking(); } From 960b4c816b92680d74b16e54d06eeca7e7eb91b2 Mon Sep 17 00:00:00 2001 From: Seasoft Date: Fri, 26 Jul 2024 16:20:23 +0900 Subject: [PATCH 16/18] =?UTF-8?q?iSC=5FResponse::sendRedirect()=20transact?= =?UTF-8?q?ionid=3D=20=E3=82=92=E7=94=BB=E4=B8=80=E7=9A=84=E3=81=AB?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=9B=E3=81=9A=E3=80=81=E4=B8=80=E5=AE=9A?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E3=81=A7=E3=81=AE=E7=B6=99=E6=89=BF=E3=81=AE?= =?UTF-8?q?=E3=81=BF=E3=81=A8=E3=81=99=E3=82=8B=20#922?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/class/SC_Response.php | 18 +- .../SC_ResponseSendRedirectWithHeaderTest.php | 291 ++++++++++++++++++ .../SC_Response/SC_ResponseWithHeaderTest.php | 73 +---- tests/class/fixtures/server/common.php | 4 +- .../server/sc_response_reload.expected | 2 +- .../fixtures/server/sc_response_reload.php | 7 +- .../sc_response_reload_add_transactionid.php | 11 - .../server/sc_response_sendRedirect.expected | 7 + .../server/sc_response_sendRedirect.php | 33 ++ 9 files changed, 355 insertions(+), 91 deletions(-) create mode 100644 tests/class/SC_Response/SC_ResponseSendRedirectWithHeaderTest.php delete mode 100644 tests/class/fixtures/server/sc_response_reload_add_transactionid.php create mode 100644 tests/class/fixtures/server/sc_response_sendRedirect.expected create mode 100644 tests/class/fixtures/server/sc_response_sendRedirect.php diff --git a/data/class/SC_Response.php b/data/class/SC_Response.php index f9890a3f88..09c9531076 100644 --- a/data/class/SC_Response.php +++ b/data/class/SC_Response.php @@ -121,13 +121,13 @@ public static function actionExit() /** * アプリケーション内でリダイレクトする * - * 内部で生成する URL の searchpart は、下記の順で上書きしていく。(後勝ち) + * 内部で生成する URL のクエリは、下記の順で上書きしていく。(後勝ち) * 1. 引数 $inheritQueryString が true の場合、$_SERVER['QUERY_STRING'] - * 2. $location に含まれる searchpart + * 2. $location に含まれる クエリ * 3. 引数 $arrQueryString * @param string $location 「url-path」「現在のURLからのパス」「URL」のいずれか。「../」の解釈は行なわない。 - * @param array $arrQueryString URL に付加する searchpart - * @param bool $inheritQueryString 現在のリクエストの searchpart を継承するか + * @param array $arrQueryString URL に付加するクエリ + * @param bool $inheritQueryString 現在のリクエストのクエリを継承するか * @param bool|null $useSsl true:HTTPSを強制, false:HTTPを強制, null:継承 * @return void * @static @@ -230,7 +230,15 @@ public static function sendRedirect($location, $arrQueryString = array(), $inher * transactionid を受け取ったリクエストに関して、値を継承してリダイレクトする。 * @see https://github.com/EC-CUBE/ec-cube2/issues/922 */ - if (isset($_REQUEST[TRANSACTION_ID_NAME]) && !isset($netUrl->querystring[TRANSACTION_ID_NAME])) { + if (// 管理機能 (本来遷移先で判定すべきだが、簡易的に遷移元で判定している。) + GC_Utils_Ex::isAdminFunction() + // 遷移元 transactionid 指定あり + && isset($_REQUEST[TRANSACTION_ID_NAME]) + // リダイレクト先 mode 指定あり + && isset($netUrl->querystring['mode']) + // リダイレクト先 transactionid 指定なし + && !isset($netUrl->querystring[TRANSACTION_ID_NAME]) + ) { $netUrl->addQueryString(TRANSACTION_ID_NAME, $_REQUEST[TRANSACTION_ID_NAME]); } diff --git a/tests/class/SC_Response/SC_ResponseSendRedirectWithHeaderTest.php b/tests/class/SC_Response/SC_ResponseSendRedirectWithHeaderTest.php new file mode 100644 index 0000000000..680aacfbab --- /dev/null +++ b/tests/class/SC_Response/SC_ResponseSendRedirectWithHeaderTest.php @@ -0,0 +1,291 @@ + ['file', '/dev/null', 'w'], + 2 => ['file', '/dev/null', 'w'] + ]; + + if (!self::$server = @proc_open('exec php -S 127.0.0.1:8085', $spec, $pipes, __DIR__.'/'.self::FIXTURES_DIR)) { + self::markTestSkipped('PHP server unable to start.'); + } + sleep(1); + } + + public static function tearDownAfterClass() + { + if (is_resource(self::$server)) { + proc_terminate(self::$server); + proc_close(self::$server); + } + } + + /** + * @param array $arrPostData + * @param array $arrTestHeader エスケープせず HTTP ヘッダーに埋め込むので注意。 + * @param array|null $arrPostData + * @return void + */ + private function request($arrQuery = [], $arrTestHeader = [], $arrPostData = null) + { + $netUrl = new Net_URL('http://127.0.0.1:8085/sc_response_sendRedirect.php'); + $netUrl->querystring = $arrQuery; + $url = $netUrl->getUrl(); + + $arrOptions = [ + 'http' => [ + 'follow_location' => 0, + 'header' => [], + ], + ]; + + if (isset($arrPostData)) { + $arrOptions['http']['method'] = 'POST'; + $arrOptions['http']['header'][] = 'Content-Type: application/x-www-form-urlencoded'; + $arrOptions['http']['content'] = http_build_query($arrPostData, '', '&'); + } + foreach ($arrTestHeader as $key => $value) { + $arrOptions['http']['header'][] = "X-Test-{$key}: {$value}"; + } + + $contents = file_get_contents($url, false, stream_context_create($arrOptions)); + + return $contents; + } + + /** + * @param array $arrQuerystring + * @return string + */ + private function getExpectedContents($arrQuerystring = []) + { + $netUrl = new Net_URL('http://127.0.0.1:8085/redirect_url.php'); + $netUrl->querystring = $arrQuerystring; + $url = $netUrl->getUrl(); + + $contents = file_get_contents(__DIR__ . '/' . self::FIXTURES_DIR . '/sc_response_sendRedirect.expected'); + $contents = str_replace('{url}', $url, $contents); + + return $contents; + } + + /** + * 以下は、sendRedirect で transactionid が付加されないパターン。 + */ + public function testSendRedirect_Admin_GRG_transactionidなし_遷移先にmode() + { + $arrQuery = [ + ]; + $arrTestHeader = [ + 'function' => 'admin', + 'dst_mode' => 'hoge', + ]; + $actual = $this->request($arrQuery, $arrTestHeader); + + $expected = $this->getExpectedContents([ + 'mode' => 'hoge', + ]); + + self::assertSame($expected, $actual); + } + + public function testSendRedirect_Admin_PRG_リクエストにtransactionid_modeなし() + { + $arrQuery = [ + TRANSACTION_ID_NAME => 'on_reqest_query', + ]; + $arrTestHeader = [ + 'function' => 'admin', + ]; + $arrPostData = [ + 'foo' => 'bar', + TRANSACTION_ID_NAME => 'on_reqest_post', + ]; + $actual = $this->request($arrQuery, $arrTestHeader, $arrPostData); + + $expected = $this->getExpectedContents(); + + self::assertSame($expected, $actual); + } + + public function testSendRedirect_Front_GRG_リクエストにtransactionid_遷移先にmode() + { + $arrQuery = [ + TRANSACTION_ID_NAME => 'on_reqest_query', + ]; + $arrTestHeader = [ + 'function' => 'front', + 'dst_mode' => 'hoge', + ]; + $actual = $this->request($arrQuery, $arrTestHeader); + + $expected = $this->getExpectedContents([ + 'mode' => 'hoge', + ]); + + self::assertSame($expected, $actual); + } + + public function testSendRedirect_Front_PRG_リクエストにtransactionid_遷移先にmode() + { + $arrQuery = [ + TRANSACTION_ID_NAME => 'on_reqest_query', + ]; + $arrTestHeader = [ + 'function' => 'front', + 'dst_mode' => 'hoge', + ]; + $arrPostData = [ + 'foo' => 'bar', + TRANSACTION_ID_NAME => 'on_reqest_post', + ]; + $actual = $this->request($arrQuery, $arrTestHeader, $arrPostData); + + $expected = $this->getExpectedContents([ + 'mode' => 'hoge', + ]); + + self::assertSame($expected, $actual); + } + + /** + * 以下は、sendRedirect で リクエストの transactionid がリダイレクト先に引き継がれるパターン。 + */ + public function testSendRedirect_Admin_GRG_リクエストにtransactionid_遷移先にmode() + { + $arrQuery = [ + TRANSACTION_ID_NAME => 'on_reqest_query', + ]; + $arrTestHeader = [ + 'function' => 'admin', + 'dst_mode' => 'hoge', + ]; + $actual = $this->request($arrQuery, $arrTestHeader); + + $expected = $this->getExpectedContents([ + 'mode' => 'hoge', + TRANSACTION_ID_NAME => 'on_reqest_query', + ]); + + self::assertSame($expected, $actual); + } + + public function testSendRedirect_Admin_PRG_リクエストにtransactionid_遷移先にmode() + { + $arrQuery = [ + TRANSACTION_ID_NAME => 'on_reqest_query', + ]; + $arrTestHeader = [ + 'function' => 'admin', + 'dst_mode' => 'hoge', + ]; + $arrPostData = [ + 'foo' => 'bar', + TRANSACTION_ID_NAME => 'on_reqest_post', + ]; + $actual = $this->request($arrQuery, $arrTestHeader, $arrPostData); + + $expected = $this->getExpectedContents([ + 'mode' => 'hoge', + TRANSACTION_ID_NAME => 'on_reqest_post', + ]); + + self::assertSame($expected, $actual); + } + + public function testSendRedirect_Admin_GRG_リクエストにtransactionid_modeなし_クエリ継承() + { + $arrQuery = [ + TRANSACTION_ID_NAME => 'on_reqest_query', + ]; + $arrTestHeader = [ + 'function' => 'admin', + 'inherit_query_string' => '1', + ]; + $actual = $this->request($arrQuery, $arrTestHeader); + + $expected = $this->getExpectedContents([ + TRANSACTION_ID_NAME => 'on_reqest_query', + ]); + + self::assertSame($expected, $actual); + } + + public function testSendRedirect_Admin_PRG_リクエストにtransactionid_modeなし_クエリ継承() + { + $arrQuery = [ + TRANSACTION_ID_NAME => 'on_reqest_query', + ]; + $arrTestHeader = [ + 'function' => 'admin', + 'inherit_query_string' => '1', + ]; + $arrPostData = [ + 'foo' => 'bar', + TRANSACTION_ID_NAME => 'on_reqest_post', + ]; + $actual = $this->request($arrQuery, $arrTestHeader, $arrPostData); + + $expected = $this->getExpectedContents([ + TRANSACTION_ID_NAME => 'on_reqest_query', + ]); + + self::assertSame($expected, $actual); + } + + /** + * 以下は、sendRedirect で ロジックの transactionid がリダイレクト先に渡るパターン。 + * + * 通常無さそうなケースだが、仕様として持っている動作。リダイレクトのタイミングで transactionid を更新する用途を想定。 + */ + public function testSendRedirect_Admin_GRG_ロジック・リクエストにtransactionid_遷移先にmode() + { + $arrQuery = [ + TRANSACTION_ID_NAME => 'on_reqest_query', + ]; + $arrTestHeader = [ + 'function' => 'admin', + 'dst_mode' => 'hoge', + 'logic_transaction_id' => 'on_logic', + ]; + $actual = $this->request($arrQuery, $arrTestHeader); + + $expected = $this->getExpectedContents([ + 'mode' => 'hoge', + TRANSACTION_ID_NAME => 'on_logic', + ]); + + self::assertSame($expected, $actual); + } + + public function testSendRedirect_Admin_PRG_ロジック・リクエストにtransactionid_遷移先にmode() + { + $arrQuery = [ + TRANSACTION_ID_NAME => 'on_reqest_query', + ]; + $arrTestHeader = [ + 'function' => 'admin', + 'dst_mode' => 'hoge', + 'logic_transaction_id' => 'on_logic', + ]; + $arrPostData = [ + 'foo' => 'bar', + TRANSACTION_ID_NAME => 'on_reqest_post', + ]; + $actual = $this->request($arrQuery, $arrTestHeader, $arrPostData); + + $expected = $this->getExpectedContents([ + 'mode' => 'hoge', + TRANSACTION_ID_NAME => 'on_logic', + ]); + + self::assertSame($expected, $actual); + } +} diff --git a/tests/class/SC_Response/SC_ResponseWithHeaderTest.php b/tests/class/SC_Response/SC_ResponseWithHeaderTest.php index 5b8a9fb766..55cd0a4713 100644 --- a/tests/class/SC_Response/SC_ResponseWithHeaderTest.php +++ b/tests/class/SC_Response/SC_ResponseWithHeaderTest.php @@ -13,7 +13,7 @@ public static function setUpBeforeClass() 2 => ['file', '/dev/null', 'w'] ]; - if (!self::$server = @proc_open('exec php -S 127.0.0.1:8053', $spec, $pipes, __DIR__.'/'.self::FIXTURES_DIR)) { + if (!self::$server = @proc_open('exec php -S 127.0.0.1:8085', $spec, $pipes, __DIR__.'/'.self::FIXTURES_DIR)) { self::markTestSkipped('PHP server unable to start.'); } sleep(1); @@ -27,77 +27,16 @@ public static function tearDownAfterClass() } } - private function file_get_contents($url) + public function testReload() { $context = stream_context_create( [ 'http' => [ - 'follow_location' => 0, - ], + 'follow_location' => false + ] ] ); - - $contents = file_get_contents($url, false, $context); - - return $contents; - } - - private function getExpectedContents($url, $additional_query_strings = '') - { - $contents = file_get_contents(__DIR__ . '/' . self::FIXTURES_DIR . '/sc_response_reload.expected'); - - $url .= ''; - - if (strlen($additional_query_strings) >= 1) { - $url .= '&' . $additional_query_strings; - } - - $contents = str_replace('{url}', $url, $contents); - - return $contents; - } - - public function testReload_transactionidが絡まない() - { - $request_url = 'http://127.0.0.1:8053/sc_response_reload.php?debug=' . urlencode('テスト'); - $expected_url = $request_url . '&redirect=1'; - $expected = $this->getExpectedContents($expected_url); - - $actual = $this->file_get_contents($request_url); - self::assertSame($expected, $actual); - } - - public function testReload_リクエストにtransactionidを含む() - { - $request_url = 'http://127.0.0.1:8053/sc_response_reload.php?debug=' . urlencode('テスト') . '&' . TRANSACTION_ID_NAME . '=on_reqest'; - $expected_url = $request_url . '&redirect=1'; - $expected = $this->getExpectedContents($expected_url); - - $actual = $this->file_get_contents($request_url); - self::assertSame($expected, $actual); - } - - public function testReload_ロジックにtransactionidを含む() - { - $request_url = 'http://127.0.0.1:8053/sc_response_reload_add_transactionid.php?debug=' . urlencode('テスト'); - $expected_url = $request_url . '&redirect=1&' . TRANSACTION_ID_NAME . '=on_logic'; - $expected = $this->getExpectedContents($expected_url); - - $actual = $this->file_get_contents($request_url); - self::assertSame($expected, $actual); - } - - public function testReload_ロジック・リクエストにtransactionidを含む() - { - $base_url = 'http://127.0.0.1:8053/sc_response_reload_add_transactionid.php?debug=' . urlencode('テスト'); - $request_url = $base_url; - $request_url .= '&' . TRANSACTION_ID_NAME . '=on_reqest'; - $expected_url = $base_url; - $expected_url .= '&' . TRANSACTION_ID_NAME . '=on_logic'; - $expected_url .= '&redirect=1'; - $expected = $this->getExpectedContents($expected_url); - - $actual = $this->file_get_contents($request_url); - self::assertSame($expected, $actual); + $actual = file_get_contents('http://127.0.0.1:8085/sc_response_reload.php', false, $context); + self::assertStringEqualsFile(__DIR__.'/'.self::FIXTURES_DIR.'/sc_response_reload.expected', $actual); } } diff --git a/tests/class/fixtures/server/common.php b/tests/class/fixtures/server/common.php index 28d5837fd2..9d675a8d79 100644 --- a/tests/class/fixtures/server/common.php +++ b/tests/class/fixtures/server/common.php @@ -1,8 +1,8 @@ Content-Type: text/plain; charset=utf-8 - [1] => Location: {url} + [1] => Location: http://127.0.0.1:8085/index.php?debug=%E3%83%86%E3%82%B9%E3%83%88&redirect=1 ) shutdown diff --git a/tests/class/fixtures/server/sc_response_reload.php b/tests/class/fixtures/server/sc_response_reload.php index 0ed10702c6..63e8df8511 100644 --- a/tests/class/fixtures/server/sc_response_reload.php +++ b/tests/class/fixtures/server/sc_response_reload.php @@ -2,10 +2,7 @@ require __DIR__.'/common.php'; -/** - * この値は使われない。 - * @see https://github.com/EC-CUBE/ec-cube2/issues/922 - */ -$_SESSION[TRANSACTION_ID_NAME] = 'on_session'; +$_SERVER['REQUEST_URI'] = HTTPS_URL.'index.php?debug='.urlencode('テスト'); +$_SESSION[TRANSACTION_ID_NAME] = 'aaaa'; SC_Response_Ex::reload(['redirect' => 1]); diff --git a/tests/class/fixtures/server/sc_response_reload_add_transactionid.php b/tests/class/fixtures/server/sc_response_reload_add_transactionid.php deleted file mode 100644 index 1fba3ea491..0000000000 --- a/tests/class/fixtures/server/sc_response_reload_add_transactionid.php +++ /dev/null @@ -1,11 +0,0 @@ - 1, TRANSACTION_ID_NAME => 'on_logic']); diff --git a/tests/class/fixtures/server/sc_response_sendRedirect.expected b/tests/class/fixtures/server/sc_response_sendRedirect.expected new file mode 100644 index 0000000000..a828def87c --- /dev/null +++ b/tests/class/fixtures/server/sc_response_sendRedirect.expected @@ -0,0 +1,7 @@ + +Array +( + [0] => Content-Type: text/plain; charset=utf-8 + [1] => Location: {url} +) +shutdown diff --git a/tests/class/fixtures/server/sc_response_sendRedirect.php b/tests/class/fixtures/server/sc_response_sendRedirect.php new file mode 100644 index 0000000000..b6dbbcbcf4 --- /dev/null +++ b/tests/class/fixtures/server/sc_response_sendRedirect.php @@ -0,0 +1,33 @@ += 1) { + $url .= '?mode=' . $arrHeader['X-Test-dst_mode']; +} + +if (strlen($arrHeader['X-Test-logic_transaction_id'] ?? '') >= 1) { + $arrQueryString[TRANSACTION_ID_NAME] = $arrHeader['X-Test-logic_transaction_id']; +} + +$inherit_query_string = ($arrHeader['X-Test-inherit_query_string'] ?? '') === '1'; + +SC_Response_Ex::sendRedirect($url, $arrQueryString, $inherit_query_string); From a09269a77362db447e7e059ed1322edaa884761e Mon Sep 17 00:00:00 2001 From: Seasoft Date: Sat, 27 Jul 2024 10:04:44 +0900 Subject: [PATCH 17/18] =?UTF-8?q?SC=5FResponse::sendRedirect()=20transacti?= =?UTF-8?q?onid=3D=20=E3=82=92=E7=94=BB=E4=B8=80=E7=9A=84=E3=81=AB?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=9B=E3=81=9A=E3=80=81=E4=B8=80=E5=AE=9A?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E3=81=A7=E3=81=AE=E7=B6=99=E6=89=BF=E3=81=AE?= =?UTF-8?q?=E3=81=BF=E3=81=A8=E3=81=99=E3=82=8B=20#922?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit コミット漏れ。 --- tests/class/fixtures/server/sc_response_sendRedirect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/class/fixtures/server/sc_response_sendRedirect.php b/tests/class/fixtures/server/sc_response_sendRedirect.php index b6dbbcbcf4..e1f106c689 100644 --- a/tests/class/fixtures/server/sc_response_sendRedirect.php +++ b/tests/class/fixtures/server/sc_response_sendRedirect.php @@ -16,7 +16,7 @@ if (($arrHeader['X-Test-function'] ?? '') === 'admin') { define('ADMIN_FUNCTION', true); } -else { +elseif (($arrHeader['X-Test-function'] ?? '') === 'front') { define('FRONT_FUNCTION', true); } From d1202bd24983ee0e33436abdd8c68a59c64e5995 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Mon, 29 Jul 2024 17:43:05 +0900 Subject: [PATCH 18/18] =?UTF-8?q?SC=5FView.php=20=E3=81=AB=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B=E6=97=A8?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E8=A8=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/smarty_extends/README.md | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/data/smarty_extends/README.md b/data/smarty_extends/README.md index 7d2a6dcaf6..0158e57bc7 100644 --- a/data/smarty_extends/README.md +++ b/data/smarty_extends/README.md @@ -1,6 +1,6 @@ ## このディレクトリのファイルは composer.json の autoload.classmap.files に登録することで利用可能です -1. autoload.classmap.files に登録します。 +1. [composer.json](../../composer.json) の autoload.classmap.files に登録します。 ``` json "autoload": { @@ -19,9 +19,27 @@ ] } ``` - -2. composer dump-autoload コマンドを実行することで autoload の対象となります。 - +2. [SC_View.php](../class/SC_View.php) のコンストラクタに modifier を設定します。 +```diff +--- a/data/class/SC_View.php ++++ b/data/class/SC_View.php +@@ -54,7 +54,13 @@ public function init() + $this->_smarty->registerPlugin('modifier', 'sfMultiply', array('SC_Utils_Ex', 'sfMultiply')); + $this->_smarty->registerPlugin('modifier', 'sfRmDupSlash', array('SC_Utils_Ex', 'sfRmDupSlash')); + $this->_smarty->registerPlugin('modifier', 'sfCutString', array('SC_Utils_Ex', 'sfCutString')); +- $this->_smarty->addPluginsDir(array('plugins', realpath(dirname(__FILE__)) . '/../smarty_extends')); ++ $this->_smarty->registerPlugin('function', 'from_to', 'smarty_function_from_to'); ++ $this->_smarty->registerPlugin('function', 'include_php_ex', 'smarty_function_include_php_ex'); ++ $this->_smarty->registerPlugin('modifier', 'h', 'smarty_modifier_h'); ++ $this->_smarty->registerPlugin('modifier', 'n2s', 'smarty_modifier_n2s'); ++ $this->_smarty->registerPlugin('modifier', 'nl2br_html', 'smarty_modifier_nl2br_html'); ++ $this->_smarty->registerPlugin('modifier', 'script_escape', 'smarty_modifier_script_escape'); ++ $this->_smarty->registerPlugin('modifier', 'u', 'smarty_modifier_u'); + $this->_smarty->registerPlugin('modifier', 'sfMbConvertEncoding', array('SC_Utils_Ex', 'sfMbConvertEncoding')); + $this->_smarty->registerPlugin('modifier', 'sfGetEnabled', array('SC_Utils_Ex', 'sfGetEnabled')); + $this->_smarty->registerPlugin('modifier', 'sfNoImageMainList', array('SC_Utils_Ex', 'sfNoImageMainList')); +``` +3. composer dump-autoload コマンドを実行することで autoload の対象となります。 ``` shell composer dump-autoload ```