Skip to content

Commit 0417725

Browse files
boneliferclaude
andauthored
Run EPV through the organization's strict EPV workflow (#90)
Switches the wiki's EPV (Extension Pre Validator) check to the organization's strict EPV workflow, `phpbbmodders/.github/.github/workflows/epv.yml@v1` (phpbbmodders/.github#2), as piloted in phpbbmodders/contactadmin#46. **Why** - EPV exits 0 unless it finds a Fatal problem, so its Error findings never failed this workflow. - Pointing EPV at the extension folder made it report a false "Packaging structure" error. The shared workflow points it at `phpBB/ext/` instead. - The shared workflow fails on any Fatal or Error finding that isn't listed, with a reason, in the extension's `.github/epv-allowed.txt`. **Changes** - `tests.yml`: both phpbb-extensions/test-framework calls (3.3.x and master) get `EPV: 0`, so EPV doesn't run twice. A new `epv` job calls the shared workflow for phpBB 3.3.x and master, matching the extension's `<4.1` phpBB range. - 29 `htmlspecialchars($value, ENT_COMPAT, 'UTF-8')` calls in 12 files now use phpBB's `utf8_htmlspecialchars($value)`, which is exactly the same call, so output doesn't change. - New `.github/epv-allowed.txt` for the findings kept on purpose: - `htmlspecialchars` with `ENT_QUOTES` in `event/wikilink_listener.php`, `wiki/markup.php` and `wiki/templates.php` (anchors, table of contents, link fragments), and with `ENT_NOQUOTES | ENT_XML1` in `wiki/discussion.php`. `utf8_htmlspecialchars()` can't pass those flags. - `addslashes` in `controller/acp_search.php`: the progress-bar URL for a JavaScript string, as in phpBB 4.0's own `acp_search.php`. - `unserialize` in `ext.php`: phpBB's own migration dependency lists and reparser resume point, read with `allowed_classes` off when an old install is moved. - Released migrations `update_0_2_0`, `update_0_3_0`, `update_0_3_1` and `update_0_3_2` without `revert_schema()`: they add columns to `wiki_article`, which `initial_module`'s `revert_schema()` drops with the whole table. Released migrations must not be changed. **Testing** Claude ran: - EPV locally on this branch with `dev-master` (on PHP 8.4, and on PHP 7.4 as the 3.3.x job does) and with `dev-epv-phpbb4`. Each time it reports 17 Errors, all in the allowlist, and the shared workflow's filter passes. - The wiki's PHPUnit suite on phpBB 3.3.x: 356 tests pass. - `php-lint.sh --strict` on PHP 8.2 and 8.4 (the extension needs 8.2): clean. This PR's CI is the first run of the new job here. --- Investigated and written by [Claude](https://www.anthropic.com/claude) on behalf of William Jacoby ([bonelifer](https://github.com/bonelifer)). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a9972df commit 0417725

14 files changed

Lines changed: 72 additions & 29 deletions

‎.github/epv-allowed.txt‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# EPV findings this extension keeps on purpose, checked by the epv job in
2+
# .github/workflows/tests.yml. One finding per line as EPV prints it, without
3+
# "on line N", with paths relative to the extension; give the reason above it.
4+
5+
# Heading anchors, the table of contents and wiki-link fragments are escaped
6+
# with ENT_QUOTES on purpose; utf8_htmlspecialchars() would only use ENT_COMPAT.
7+
Error: Using htmlspecialchars in /event/wikilink_listener.php
8+
Error: Using htmlspecialchars in /wiki/markup.php
9+
Error: Using htmlspecialchars in /wiki/templates.php
10+
11+
# Discussion text is re-encoded for XML with ENT_NOQUOTES | ENT_XML1, which
12+
# utf8_htmlspecialchars() can't do.
13+
Error: Using htmlspecialchars in /wiki/discussion.php
14+
15+
# The search index progress-bar URL is escaped for a JavaScript string, as in
16+
# phpBB's own acp_search.php.
17+
Error: Using addslashes in /controller/acp_search.php
18+
19+
# ext.php reads phpBB's own serialized migration dependency lists and the
20+
# reparser resume point when it moves an install made under the old vendor
21+
# name, with allowed_classes off, so no objects can be created.
22+
Error: Using unserialize in /ext.php
23+
24+
# Released migrations that add columns to the wiki_article table, which
25+
# initial_module's revert_schema() drops when the extension's data is deleted,
26+
# so there is nothing for these migrations to revert. Released migrations must
27+
# not be changed.
28+
Error: Migration file /migrations/update_0_2_0.php is missing the revert_schema() method.
29+
Error: Migration file /migrations/update_0_3_0.php is missing the revert_schema() method.
30+
Error: Migration file /migrations/update_0_3_1.php is missing the revert_schema() method.
31+
Error: Migration file /migrations/update_0_3_2.php is missing the revert_schema() method.

‎.github/workflows/tests.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
uses: phpbb-extensions/test-framework/.github/workflows/tests.yml@3.3.x
1919
with:
2020
EXTNAME: phpbbmodders/wiki
21+
# EPV runs in the epv job below instead
22+
EPV: 0
2123
PHPBB_BRANCH: '3.3.x'
2224
RUN_FUNCTIONAL_TESTS: 0
2325
PRIMARY_PHP_VERSION: '8.2'
@@ -29,7 +31,17 @@ jobs:
2931
uses: phpbb-extensions/test-framework/.github/workflows/tests.yml@master
3032
with:
3133
EXTNAME: phpbbmodders/wiki
34+
# EPV runs in the epv job below instead
35+
EPV: 0
3236
PHPBB_BRANCH: 'master'
3337
RUN_FUNCTIONAL_TESTS: 0
3438
PRIMARY_PHP_VERSION: '8.2'
3539
PHP_VERSION_MATRIX: '["8.2", "8.3", "8.4", "8.5"]'
40+
41+
# EPV (Extension Pre Validator), failing on any Fatal or Error finding not
42+
# listed in .github/epv-allowed.txt
43+
epv:
44+
uses: phpbbmodders/.github/.github/workflows/epv.yml@v1
45+
with:
46+
EXTNAME: phpbbmodders/wiki
47+
PHPBB_BRANCHES: '["3.3.x", "master"]'

‎controller/acp_templates.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ protected function do_check($u_action)
183183
trigger_error($this->language->lang('WIKI_STARTER_CHECK_FAILED') . adm_back_link($u_action), E_USER_WARNING);
184184
}
185185
$message = $changed
186-
? $this->language->lang('WIKI_STARTER_CHECK_CHANGES', count($changed), htmlspecialchars(implode(', ', $changed), ENT_COMPAT, 'UTF-8'))
186+
? $this->language->lang('WIKI_STARTER_CHECK_CHANGES', count($changed), utf8_htmlspecialchars(implode(', ', $changed)))
187187
: $this->language->lang('WIKI_STARTER_CHECK_NONE');
188188
trigger_error($message . adm_back_link($u_action));
189189
}
@@ -205,7 +205,7 @@ protected function do_install($u_action)
205205
trigger_error($this->language->lang('WIKI_STARTER_NOTHING_CHOSEN') . adm_back_link($u_action), E_USER_WARNING);
206206
}
207207
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_WIKI_STARTER_INSTALLED', false, array(implode(', ', $installed)));
208-
trigger_error($this->language->lang('WIKI_STARTER_INSTALLED', count($installed), htmlspecialchars(implode(', ', $installed), ENT_COMPAT, 'UTF-8')) . adm_back_link($u_action));
208+
trigger_error($this->language->lang('WIKI_STARTER_INSTALLED', count($installed), utf8_htmlspecialchars(implode(', ', $installed))) . adm_back_link($u_action));
209209
}
210210

211211
/**

‎controller/category.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public function index()
238238
'COUNT' => $count,
239239
'DESCRIPTION' => isset($descriptions[categories::normalise($name)]) ? $descriptions[categories::normalise($name)] : '',
240240
'U_CATEGORY' => $u_category,
241-
'WRITE_IN' => $this->user->lang('WIKI_CATEGORY_WRITE_IN', htmlspecialchars('[[' . categories::PREFIX . $name . ']]', ENT_COMPAT, 'UTF-8')),
241+
'WRITE_IN' => $this->user->lang('WIKI_CATEGORY_WRITE_IN', utf8_htmlspecialchars('[[' . categories::PREFIX . $name . ']]')),
242242
'MORE' => ($count > self::PREVIEW_MEMBERS) ? $this->user->lang('WIKI_CATEGORY_MORE', $count - self::PREVIEW_MEMBERS, $u_category) : '',
243243
));
244244

‎controller/template_list.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function page()
131131
'USED_ON' => count($this->links->what_links_here($row['article_url'])),
132132
'EDIT_TIME' => $this->user->format_date($row['article_last_edit']),
133133
'U_TEMPLATE' => $this->helper->route('phpbbmodders_wiki_article', array('article' => $row['article_url'])),
134-
'USAGE' => htmlspecialchars(\phpbbmodders\wiki\wiki\templates::usage($name, \phpbbmodders\wiki\wiki\templates::parameters($source)), ENT_COMPAT, 'UTF-8'),
134+
'USAGE' => utf8_htmlspecialchars(\phpbbmodders\wiki\wiki\templates::usage($name, \phpbbmodders\wiki\wiki\templates::parameters($source))),
135135
'PREVIEW' => $preview,
136136
'S_START' => strpos($name, \phpbbmodders\wiki\wiki\templates::START_PREFIX) === 0,
137137
));

‎event/wikilink_listener.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ public function link_wikilinks($event)
407407
}
408408

409409
return '<a class="wikilink wikilink-new" href="' . $url . '" data-wiki-article="' . $match[1] . '" title="'
410-
. htmlspecialchars($this->language->lang('WIKI_LINK_NEW_ARTICLE'), ENT_COMPAT, 'UTF-8') . '">';
410+
. utf8_htmlspecialchars($this->language->lang('WIKI_LINK_NEW_ARTICLE')) . '">';
411411
}, $html);
412412
}
413413

@@ -441,7 +441,7 @@ protected function embed_files($html)
441441

442442
if (!isset($found[$name]))
443443
{
444-
return '<span class="wikifile wikifile-missing" title="' . htmlspecialchars($this->language->lang('WIKI_FILE_MISSING', $name), ENT_COMPAT, 'UTF-8') . '">' . $alt . '</span>';
444+
return '<span class="wikifile wikifile-missing" title="' . utf8_htmlspecialchars($this->language->lang('WIKI_FILE_MISSING', $name)) . '">' . $alt . '</span>';
445445
}
446446

447447
$url = $this->files->get_url($article, $found[$name]['file_id']);

‎wiki/categories.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public static function names_in($stored)
155155
*/
156156
protected function members_where($category)
157157
{
158-
$needle = '<WIKICATEGORY name="' . htmlspecialchars(self::normalise($category), ENT_COMPAT, 'UTF-8') . '"';
158+
$needle = '<WIKICATEGORY name="' . utf8_htmlspecialchars(self::normalise($category)) . '"';
159159

160160
return $this->templates->live_where('a', '') . '
161161
AND a.article_text ' . $this->db->sql_like_expression($this->db->get_any_char() . $needle . $this->db->get_any_char());

‎wiki/edit.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ public function edit_article($article)
472472
$redirect_target = \phpbbmodders\wiki\wiki\markup::redirect_target(htmlspecialchars_decode($this->data['article_text'], ENT_COMPAT));
473473
if ($redirect_target !== '' && $this->auth->acl_get('u_wiki_set_redirect') && empty($this->data['article_redirect']))
474474
{
475-
$this->data['article_redirect'] = htmlspecialchars($redirect_target, ENT_COMPAT, 'UTF-8');
475+
$this->data['article_redirect'] = utf8_htmlspecialchars($redirect_target);
476476
}
477477

478478
\phpbbmodders\wiki\wiki\markup::set_active(true);
@@ -718,7 +718,7 @@ protected function offer_start_templates($article)
718718
$text = $this->copy_text($copy_from);
719719
if ($text === null)
720720
{
721-
$error = $this->user->lang('WIKI_START_COPY_NOT_FOUND', htmlspecialchars($copy_from, ENT_COMPAT, 'UTF-8'));
721+
$error = $this->user->lang('WIKI_START_COPY_NOT_FOUND', utf8_htmlspecialchars($copy_from));
722722
}
723723
}
724724
else if ($chosen !== '')
@@ -757,7 +757,7 @@ protected function offer_start_templates($article)
757757
if ($text !== null)
758758
{
759759
// The text box takes text escaped as decode_message() leaves it
760-
$this->message_parser->message = htmlspecialchars($text, ENT_COMPAT, 'UTF-8');
760+
$this->message_parser->message = utf8_htmlspecialchars($text);
761761
}
762762

763763
foreach ($options as $option)
@@ -771,7 +771,7 @@ protected function offer_start_templates($article)
771771

772772
$this->template->assign_vars(array(
773773
'S_START_PICKER' => true,
774-
'START_COPY_FROM' => htmlspecialchars($copy_from, ENT_COMPAT, 'UTF-8'),
774+
'START_COPY_FROM' => utf8_htmlspecialchars($copy_from),
775775
'START_ERROR' => $error,
776776
'U_START_ACTION' => $this->helper->route('phpbbmodders_wiki_article', array('article' => $article)),
777777
));
@@ -789,9 +789,9 @@ protected function ask_start_values(array $parameters)
789789
foreach ($parameters as $name => $default)
790790
{
791791
$this->template->assign_block_vars('start_values', array(
792-
'NAME' => htmlspecialchars((string) $name, ENT_COMPAT, 'UTF-8'),
793-
'LABEL' => ctype_digit((string) $name) ? $this->user->lang('WIKI_START_VALUE_NUMBERED', (int) $name) : htmlspecialchars((string) $name, ENT_COMPAT, 'UTF-8'),
794-
'DEFAULT' => htmlspecialchars($default, ENT_COMPAT, 'UTF-8'),
792+
'NAME' => utf8_htmlspecialchars((string) $name),
793+
'LABEL' => ctype_digit((string) $name) ? $this->user->lang('WIKI_START_VALUE_NUMBERED', (int) $name) : utf8_htmlspecialchars((string) $name),
794+
'DEFAULT' => utf8_htmlspecialchars($default),
795795
));
796796
}
797797
$this->template->assign_var('S_START_VALUES', true);

‎wiki/links.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ public function what_links_here($name)
7373
// Links are stored in the parsed text as <WIKILINK name="...">, and {{template}} calls
7474
// as <WIKITEMPLATE call="..." name="..."> (attributes in alphabetical order).
7575
$any = $this->db->get_any_char();
76-
$escaped = htmlspecialchars($name, ENT_COMPAT, 'UTF-8');
76+
$escaped = utf8_htmlspecialchars($name);
7777
$conditions = array(
7878
'article_text ' . $this->db->sql_like_expression($any . '<WIKILINK name="' . $escaped . '"' . $any),
7979
);
8080
if (strpos($name, \phpbbmodders\wiki\wiki\templates::PREFIX) === 0)
8181
{
82-
$template = htmlspecialchars(substr($name, strlen(\phpbbmodders\wiki\wiki\templates::PREFIX)), ENT_COMPAT, 'UTF-8');
82+
$template = utf8_htmlspecialchars(substr($name, strlen(\phpbbmodders\wiki\wiki\templates::PREFIX)));
8383
foreach (array($template, $escaped) as $written)
8484
{
8585
$conditions[] = 'article_text ' . $this->db->sql_like_expression($any . '<WIKITEMPLATE ' . $any . ' name="' . $written . '">' . $any);

‎wiki/move.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function page($article)
156156
}
157157
else if ($this->taken($new_name, $article))
158158
{
159-
$errors[] = $this->user->lang('WIKI_MOVE_NAME_TAKEN', htmlspecialchars($new_name, ENT_COMPAT, 'UTF-8'));
159+
$errors[] = $this->user->lang('WIKI_MOVE_NAME_TAKEN', utf8_htmlspecialchars($new_name));
160160
}
161161
if ($new_title === '' || utf8_strlen(htmlspecialchars_decode($new_title, ENT_COMPAT)) > 255)
162162
{
@@ -183,8 +183,8 @@ public function page($article)
183183
));
184184
$this->template->assign_vars(array(
185185
'ERROR' => implode('<br />', $errors),
186-
'ARTICLE_NAME' => htmlspecialchars($article, ENT_COMPAT, 'UTF-8'),
187-
'NEW_NAME' => htmlspecialchars($new_name, ENT_COMPAT, 'UTF-8'),
186+
'ARTICLE_NAME' => utf8_htmlspecialchars($article),
187+
'NEW_NAME' => utf8_htmlspecialchars($new_name),
188188
'NEW_TITLE' => $new_title,
189189
'S_LEAVE_REDIRECT' => $leave_redirect,
190190
'TEMPLATE_USED_BY' => $used_by ? $this->user->lang('WIKI_MOVE_TEMPLATE_WARNING', $used_by) : '',
@@ -208,7 +208,7 @@ protected function template_users($article)
208208
$sql = 'SELECT article_url
209209
FROM ' . $this->article_table . "
210210
WHERE article_approved = 1
211-
AND article_redirect = '" . $this->db->sql_escape(htmlspecialchars($article, ENT_COMPAT, 'UTF-8')) . "'
211+
AND article_redirect = '" . $this->db->sql_escape(utf8_htmlspecialchars($article)) . "'
212212
AND article_url " . $this->db->sql_like_expression(templates::PREFIX . $this->db->get_any_char());
213213
$result = $this->db->sql_query($sql);
214214
while ($row = $this->db->sql_fetchrow($result))
@@ -304,7 +304,7 @@ protected function move_article($old, $new, $title, $leave_redirect, $old_title)
304304
'article_sources' => '',
305305
'article_sticky' => 0,
306306
'article_views' => 0,
307-
'article_redirect' => htmlspecialchars($new, ENT_COMPAT, 'UTF-8'),
307+
'article_redirect' => utf8_htmlspecialchars($new),
308308
'article_description' => '',
309309
'article_toc' => '',
310310
)));

0 commit comments

Comments
 (0)