Page MenuHomePhabricator

Fix for handling of sections with special characters in their name such as "(", ")", "+"
Closed, ResolvedPublic

Description

the pageforms find sections has a bug with section title has special characters such as "(", ")", "+".
e.g. ===age (10-20)===

as i don't know how can i commit a pull request for it. so i attach my patch file content, thx.

Index: extensions/PageForms/includes/PF_FormPrinter.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- extensions/PageForms/includes/PF_FormPrinter.php	(revision ed14ff91f8507fe2dd8e3d4a2baf07ca8eef6117)
+++ extensions/PageForms/includes/PF_FormPrinter.php	(date 1582622681838)
@@ -1353,7 +1353,7 @@
 							$tag_components_next_section = PFUtils::getFormTagComponents( $bracketed_string_next_section );
 							$tag_title_next_section = trim( $tag_components_next_section[0] );
 							if ( $tag_title_next_section == 'section' ) {
-								if ( preg_match( '/(^={1,6}[ ]*?' . $tag_components_next_section[1] . '[ ]*?={1,6}\s*?$)/m', $existing_page_content, $matches, PREG_OFFSET_CAPTURE ) ) {
+								if ( preg_match( '/(^={1,6}[ ]*?' . preg_quote($tag_components_next_section[1], '/') . '[ ]*?={1,6}\s*?$)/m', $existing_page_content, $matches, PREG_OFFSET_CAPTURE ) ) {
 									$section_end_loc = $matches[0][1];
 								}
 							}

Event Timeline

Aklapper renamed this task from a fix for pageforms bug to Find Issues when section title has special characters such as "(", ")", "+".Feb 25 2020, 12:11 PM

@Tinganwiki: Thanks for taking a look at the code! You are very welcome to use developer access to submit the proposed code changes as a Git branch directly into Gerrit which makes it easier to review and provide feedback. If you don't want to set up Git/Gerrit, you can also use the Gerrit Patch Uploader. Thanks again!

Tinganwiki claimed this task.

did uploaded the patch file. thx

did uploaded the patch file. thx

Thanks! Unfortunately we do not know where. :) Also see https://www.mediawiki.org/wiki/Gerrit/Commit_message_guidelines

Also, please do not close tasks when tasks have not been fixed.

Yaron_Koren renamed this task from Find Issues when section title has special characters such as "(", ")", "+" to Fix for handling of sections with special characters in their name such as "(", ")", "+".Feb 25 2020, 2:18 PM

Hi,
Patch uploader fails somehow. but I attached the patch file.

Result from uploading patch:

*git clone -v -v --depth=1 ssh://gerrit/mediawiki/extensions/PageForms
/tmp/tmp6hq4w32s*
*Cloning into '/tmp/tmp6hq4w32s'... Server supports multi_ack_detailed
Server supports side-band-64k Server supports ofs-delta Server version is
JGit/4.9.10.201904181027-r want 1697639ab81127886b61f9de80f2c99b1af0b29d
(HEAD) want 1697639ab81127886b61f9de80f2c99b1af0b29d (refs/heads/master)

done Total 399 (delta 39), reused 125 (delta 10) *

*git rev-parse --abbrev-ref HEAD*

*master *

*git config user.name http://user.name [[mw:User:Tinganwiki]]*

*git config user.email gerritpatchuploader@gmail.com

<gerritpatchuploader@gmail.com>*

*git apply < patch*

*error: PageForms/includes/PF_FormPrinter.php: No such file or directory *

*patch --no-backup-if-mismatch -p0 -u < patch*
*can't find file to patch at input line 8 Perhaps you used the wrong -p or
--strip option? The text leading up to this was: --------------------------

Index: extensions/PageForms/includes/PF_FormPrinter.phpIDEA additional

info: |Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP |<+>UTF-8

===================================================================---

extensions/PageForms/includes/PF_FormPrinter.php (revision
ed14ff91f8507fe2dd8e3d4a2baf07ca8eef6117) |+++
extensions/PageForms/includes/PF_FormPrinter.php (date 1582622681838)

  • File to patch: Skip this patch? [y] Skipping

patch. 1 out of 1 hunk ignored *

*patch --no-backup-if-mismatch -p1 -u < patch*
*can't find file to patch at input line 8 Perhaps you used the wrong -p or
--strip option? The text leading up to this was: --------------------------

Index: extensions/PageForms/includes/PF_FormPrinter.phpIDEA additional

info: |Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP |<+>UTF-8

===================================================================---

extensions/PageForms/includes/PF_FormPrinter.php (revision
ed14ff91f8507fe2dd8e3d4a2baf07ca8eef6117) |+++
extensions/PageForms/includes/PF_FormPrinter.php (date 1582622681838)

  • File to patch: Skip this patch? [y] Skipping

patch. 1 out of 1 hunk ignored *

*Upload failed*
Reason: *Patch failed (is your patch in unified diff format, and does it
patch apply cleanly to master?)* (check log above for details)

Change 574793 had a related patch set uploaded (by Tingan; owner: Tingan):
[mediawiki/extensions/PageForms@master] T246088: Find Issues when section title has special characters such as "(", ")", "+"

https://gerrit.wikimedia.org/r/574793

Change 574793 had a related patch set uploaded (by Nikerabbit; owner: Tingan):
[mediawiki/extensions/PageForms@master] Avoid warnings when section title has special characters such as "(", ")", "+"

https://gerrit.wikimedia.org/r/574793

Change 574927 had a related patch set uploaded (by Tingan; owner: Tingan):
[mediawiki/extensions/PageForms@master] Merge branch 'master' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageForms into T246088-fix

https://gerrit.wikimedia.org/r/574927

Change 574927 abandoned by Aklapper:
Merge branch 'master' of ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageForms into T246088-fix

Reason:
tingan: Please see https://www.mediawiki.org/wiki/Gerrit/Tutorial#Amending_a_change_.28your_own_or_someone_else.27s.29 and improve https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/PageForms/ /574793/ instead - thanks!

https://gerrit.wikimedia.org/r/574927

I think it has been resolved here T246380

I no longer see this with 4.9.2.