Skip to content

Commit 35fef30

Browse files
committed
Merge branch '3.3.x'
2 parents 1b957b2 + 3a90de2 commit 35fef30

52 files changed

Lines changed: 908 additions & 191 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- 3.3.x
7+
- master
8+
- 4.0.x
9+
pull_request:
10+
11+
jobs:
12+
lint:
13+
name: "Lint (PHP ${{ matrix.php }})"
14+
runs-on: ubuntu-22.04
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
php: ['7.4', '8.1', '8.2', '8.3']
19+
20+
steps:
21+
- uses: actions/checkout@v6
22+
23+
- uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php }}
26+
coverage: none
27+
28+
- name: Syntax check
29+
run: |
30+
find . -name '*.php' \
31+
-not -path './vendor/*' \
32+
-not -path './includes/library/*' \
33+
-not -path './composer_packages/*' \
34+
-print0 | xargs -0 -n1 -P4 php -l > /dev/null
35+
36+
coding-standards:
37+
name: Coding standards (changed files)
38+
runs-on: ubuntu-22.04
39+
if: github.event_name == 'pull_request'
40+
41+
steps:
42+
- uses: actions/checkout@v6
43+
with:
44+
fetch-depth: 0
45+
46+
- uses: shivammathur/setup-php@v2
47+
with:
48+
php-version: '8.3'
49+
coverage: none
50+
tools: cs2pr
51+
52+
- name: Fetch the phpBB coding standard
53+
run: |
54+
git clone --depth 1 --branch 3.3.x --filter=blob:none --sparse \
55+
https://github.com/phpbb/phpbb.git "$RUNNER_TEMP/phpbb"
56+
git -C "$RUNNER_TEMP/phpbb" sparse-checkout set build/code_sniffer
57+
58+
- name: Install PHP_CodeSniffer and phpcs-changed
59+
run: |
60+
composer --working-dir="$RUNNER_TEMP" require --no-interaction \
61+
squizlabs/php_codesniffer:^3.7 \
62+
sirbrillig/phpcs-changed:^2.11
63+
64+
- name: Check lines changed by this pull request
65+
run: |
66+
git fetch --no-tags origin "$GITHUB_BASE_REF"
67+
mapfile -t files < <(git diff --name-only --diff-filter=ACMR "origin/$GITHUB_BASE_REF"...HEAD -- '*.php' \
68+
| grep -vE '^(vendor|includes/library|composer_packages)/' || true)
69+
70+
if [ "${#files[@]}" -eq 0 ]; then
71+
echo "No PHP files changed."
72+
exit 0
73+
fi
74+
75+
printf '%s\n' "${files[@]}"
76+
# Only report violations this pull request introduces. Running the ruleset
77+
# over whole files would fail on the 175 pre-existing errors any time a
78+
# legacy file is touched, which would make the check useless.
79+
"$RUNNER_TEMP/vendor/bin/phpcs-changed" \
80+
--git --git-base "origin/$GITHUB_BASE_REF" \
81+
--phpcs-path "$RUNNER_TEMP/vendor/bin/phpcs" \
82+
--standard "$RUNNER_TEMP/phpbb/build/code_sniffer/ruleset-php-extensions.xml" \
83+
--report checkstyle "${files[@]}" | tee phpcs.xml
84+
exit "${PIPESTATUS[0]}"
85+
86+
- name: Annotate the pull request
87+
if: ${{ failure() }}
88+
run: cs2pr phpcs.xml
89+
90+
composer:
91+
name: Validate composer.json
92+
runs-on: ubuntu-22.04
93+
94+
steps:
95+
- uses: actions/checkout@v6
96+
97+
- uses: shivammathur/setup-php@v2
98+
with:
99+
php-version: '7.4'
100+
coverage: none
101+
102+
- name: Validate
103+
run: composer validate --no-check-all --no-check-publish

‎.gitmodules‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎.travis.yml‎

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎assets/javascript/ajax.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,23 @@
6767
$contribList = $('.contrib-list-container'),
6868
$search = $('#category-search');
6969

70+
// The address is about to change directory depth, which would make the
71+
// browser re-resolve every relative URL on the page against the new
72+
// path. Pin them to the URL the document was rendered against first.
73+
var resolver = document.createElement('a');
74+
$('a[href], form[action]').each(function() {
75+
var name = (this.nodeName === 'FORM') ? 'action' : 'href',
76+
value = this.getAttribute(name);
77+
78+
// Skip absolute URLs, protocol-relative URLs, root-relative URLs, and in-page anchors.
79+
if (!value || value[0] === '#' || value[0] === '/' || value.indexOf('//') === 0 || /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(value)) {
80+
return;
81+
}
82+
83+
resolver.href = value;
84+
this.setAttribute(name, resolver.href);
85+
});
86+
7087
phpbb.history.replaceUrl($this.attr('href'));
7188

7289
var getParents = function($self) {

‎attachment/attachment.php‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected function configure_properties()
9595
'physical_filename' => array('default' => '', 'max' => 255),
9696
'attachment_directory' => array('default' => '', 'max' => 255),
9797
'real_filename' => array('default' => '', 'max' => 255),
98-
'attachment_comment' => array('default' => ''),
98+
'attachment_comment' => array('default' => '', 'encode_ucr' => true),
9999

100100
'download_count' => array('default' => 0),
101101

@@ -202,6 +202,14 @@ public function submit($data = null)
202202

203203
if (!empty($data))
204204
{
205+
foreach ($data as $name => $value)
206+
{
207+
if (isset($this->object_config[$name]))
208+
{
209+
$data[$name] = $this->validate_property($value, $this->object_config[$name]);
210+
}
211+
}
212+
205213
$sql = 'UPDATE ' . $this->sql_table . '
206214
SET ' . $this->db->sql_build_array('UPDATE', $data) . '
207215
WHERE attachment_id = ' . $this->get_id();

‎attachment/uploader.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use phpbb\files\upload;
1717
use phpbb\request\request_interface;
1818
use phpbb\titania\access;
19+
use phpbb\titania\unicode;
1920
use phpbb\titania\ext;
2021

2122
class uploader
@@ -260,6 +261,16 @@ public function upload_file()
260261
return false;
261262
}
262263

264+
if (unicode::contains_unsupported($file->get('uploadname')))
265+
{
266+
$file->error[] = $this->user->lang('INVALID_FILENAME', $file->get('uploadname'));
267+
$file->remove();
268+
$this->filedata['error'] = array_merge($this->filedata['error'], $file->error);
269+
$this->filedata['post_attach'] = false;
270+
271+
return false;
272+
}
273+
263274
// Set max file size for anyone but team members.
264275
if (!$this->access->is_team())
265276
{

‎composer/repository.php‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,17 @@ public function dump_include($name, array $packages, $subdir = '')
180180
/**
181181
* Get include files.
182182
*
183+
* @param string $subdir Optional subdirectory
183184
* @return Finder
184185
*/
185-
protected function get_include_files()
186+
protected function get_include_files($subdir = '')
186187
{
187188
$finder = new Finder;
188189
$finder
189190
->files()
190191
->depth('== 0')
191192
->name('/^packages\-[a-z]+\-\d+\.json$/')
192-
->in($this->build_dir)
193+
->in($this->build_dir . $subdir)
193194
;
194195

195196
return $finder;
@@ -215,7 +216,7 @@ protected function build_parents()
215216
*/
216217
protected function build_parent_structure($subdir = '')
217218
{
218-
$includes = $this->get_include_files();
219+
$includes = $this->get_include_files($subdir);
219220
$parent = $types = array();
220221
$target_dir = $this->build_dir . $subdir;
221222

‎config/config.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function set_default_config()
184184
'30' => array('latest_revision' => '14', 'name' => 'phpBB 3.0.x', 'allow_uploads' => false),
185185
'31' => array('latest_revision' => '12', 'name' => 'phpBB 3.1.x', 'allow_uploads' => false),
186186
'32' => array('latest_revision' => '11', 'name' => 'phpBB 3.2.x', 'allow_uploads' => false),
187-
'33' => array('latest_revision' => '17', 'name' => 'phpBB 3.3.x', 'allow_uploads' => true),
187+
'33' => array('latest_revision' => '18', 'name' => 'phpBB 3.3.x', 'allow_uploads' => true),
188188
)),
189189

190190
// MPV server(s)

‎contribution/bbcode/type.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ protected function configure()
7777
'explain' => 'REVISION_BBCODE_USE_EXPLAIN',
7878
),
7979
'revision_bbc_help_line' => array(
80-
'type' => 'input',
80+
'type' => 'textarea',
8181
'name' => 'REVISION_HELP_LINE',
82-
'explain' => '',
82+
'explain' => 'REVISION_HELP_LINE_EXPLAIN',
8383
),
8484
'revision_bbc_demo' => array(
8585
'type' => 'textarea',

‎contribution/extension/type.php‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use phpbb\titania\attachment\attachment;
1919
use phpbb\titania\config\config as ext_config;
2020
use phpbb\titania\contribution\type\base;
21+
use phpbb\titania\unicode;
2122
use phpbb\titania\entity\package;
2223
use phpbb\user;
2324

@@ -216,7 +217,7 @@ public function epv_test(\titania_contribution $contrib, \titania_revision $revi
216217
public function validate_ext_name($name)
217218
{
218219
return (bool) preg_match(
219-
'#^[a-zA-Z0-9\x7f-\xff]{2,}/[a-zA-Z0-9\x7f-\xff]{2,}$#',
220+
'#^[a-zA-Z0-9\x{007F}-\x{FFFF}]{2,}/[a-zA-Z0-9\x{007F}-\x{FFFF}]{2,}$#u',
220221
$name
221222
);
222223
}
@@ -283,10 +284,10 @@ protected function repack(package $package, \titania_contribution $contrib, \tit
283284
$data = $this->update_phpbb_requirement($data, $revision);
284285
$data = $this->set_version_check($data, $contrib);
285286

286-
$data = json_encode(
287+
$data = unicode::escape_json(json_encode(
287288
$data,
288289
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
289-
);
290+
));
290291

291292
file_put_contents($composer_file, $data);
292293
$package->restore_root($ext_base_path, $ext_name);

0 commit comments

Comments
 (0)