EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/162308
Change subject: Don't treat topic title as wikitext
......................................................................
Don't treat topic title as wikitext
Topic titles inserted into l10n via plaintextSnippet were receiving
template substitution via Message::text().
This patch changes it arround to always output the l10n safe topic-of-post
property on topic titles so there is always a safe value to stick into
l10n when dealing with a topic title in a template.
Change-Id: I1ce7a49304abe87ec663c193461def4ee053273d
(cherry picked from commit 29d6daf34f2125ef48373621b25734b9bd87f076)
---
M handlebars/compiled/flow_block_topic.handlebars.php
M handlebars/compiled/flow_block_topic_moderate_post.handlebars.php
M handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
M handlebars/compiled/flow_block_topiclist.handlebars.php
M handlebars/compiled/flow_post.handlebars.php
M handlebars/flow_reply_form.handlebars
M handlebars/flow_topic.handlebars
M includes/Formatter/RevisionFormatter.php
M modules/new/components/flow-board.js
9 files changed, 30 insertions(+), 22 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/08/162308/1
diff --git a/handlebars/compiled/flow_block_topic.handlebars.php
b/handlebars/compiled/flow_block_topic.handlebars.php
index a549144..f4406df 100644
--- a/handlebars/compiled/flow_block_topic.handlebars.php
+++ b/handlebars/compiled/flow_block_topic.handlebars.php
@@ -344,7 +344,7 @@
data-flow-expandable="true"
class="mw-ui-input"
type="text"
- placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',LCRun3::ch($cx,
'plaintextSnippet', Array(Array(((is_array($in['content']) &&
isset($in['content']['format'])) ? $in['content']['format'] :
null),((is_array($in['content']) && isset($in['content']['content'])) ?
$in['content']['content'] : null)),Array()), 'raw')),Array()), 'encq').'"
+ placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',((is_array($in['properties'])
&& isset($in['properties']['topic-of-post'])) ?
$in['properties']['topic-of-post'] : null)),Array()), 'encq').'"
data-role="content">'.((LCRun3::ifvar($cx,
((is_array($cx['scopes'][0]) && isset($cx['scopes'][0]['submitted'])) ?
$cx['scopes'][0]['submitted'] : null))) ? ''.LCRun3::hbch($cx, 'ifCond',
Array(Array(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['postId'])) ?
$cx['scopes'][0]['submitted']['postId'] : null),'===',((is_array($in) &&
isset($in['postId'])) ? $in['postId'] : null)),Array()), $in, function($cx,
$in) {return ''.htmlentities(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['content'])) ?
$cx['scopes'][0]['submitted']['content'] : null), ENT_QUOTES, 'UTF-8').'';}).''
: '').'</textarea>
<div class="flow-form-actions flow-form-collapsible">
@@ -422,7 +422,7 @@
data-flow-expandable="true"
class="mw-ui-input"
type="text"
- placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',LCRun3::ch($cx,
'plaintextSnippet', Array(Array(((is_array($in['content']) &&
isset($in['content']['format'])) ? $in['content']['format'] :
null),((is_array($in['content']) && isset($in['content']['content'])) ?
$in['content']['content'] : null)),Array()), 'raw')),Array()), 'encq').'"
+ placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',((is_array($in['properties'])
&& isset($in['properties']['topic-of-post'])) ?
$in['properties']['topic-of-post'] : null)),Array()), 'encq').'"
data-role="content">'.((LCRun3::ifvar($cx,
((is_array($cx['scopes'][0]) && isset($cx['scopes'][0]['submitted'])) ?
$cx['scopes'][0]['submitted'] : null))) ? ''.LCRun3::hbch($cx, 'ifCond',
Array(Array(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['postId'])) ?
$cx['scopes'][0]['submitted']['postId'] : null),'===',((is_array($in) &&
isset($in['postId'])) ? $in['postId'] : null)),Array()), $in, function($cx,
$in) {return ''.htmlentities(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['content'])) ?
$cx['scopes'][0]['submitted']['content'] : null), ENT_QUOTES, 'UTF-8').'';}).''
: '').'</textarea>
<div class="flow-form-actions flow-form-collapsible">
@@ -455,7 +455,7 @@
<a
href="'.htmlentities(((is_array($in['actions']['reply']) &&
isset($in['actions']['reply']['url'])) ? $in['actions']['reply']['url'] :
null), ENT_QUOTES, 'UTF-8').'"
title="'.htmlentities(((is_array($in['actions']['reply']) &&
isset($in['actions']['reply']['title'])) ? $in['actions']['reply']['title'] :
null), ENT_QUOTES, 'UTF-8').'"
class="flow-ui-input-replacement-anchor
mw-ui-input"
- >'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',LCRun3::ch($cx,
'plaintextSnippet', Array(Array(((is_array($in['content']) &&
isset($in['content']['format'])) ? $in['content']['format'] :
null),((is_array($in['content']) && isset($in['content']['content'])) ?
$in['content']['content'] : null)),Array()), 'raw')),Array()), 'encq').'</a>
+ >'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',((is_array($in['properties'])
&& isset($in['properties']['topic-of-post'])) ?
$in['properties']['topic-of-post'] : null)),Array()), 'encq').'</a>
';}).'
' : '').'
' : '').'
@@ -467,4 +467,4 @@
</div>
';
}
-?>
\ No newline at end of file
+?>
diff --git a/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php
b/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php
index 23cd539..a318d96 100644
--- a/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php
+++ b/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php
@@ -18,7 +18,6 @@
'concat' => 'Flow\TemplateHelper::concat',
'linkWithReturnTo' => 'Flow\TemplateHelper::linkWithReturnTo',
'escapeContent' => 'Flow\TemplateHelper::escapeContent',
- 'plaintextSnippet' => 'Flow\TemplateHelper::plaintextSnippet',
),
'blockhelpers' => Array(),
'hbhelpers' => Array( 'eachPost' =>
'Flow\TemplateHelper::eachPost',
@@ -578,7 +577,7 @@
data-flow-expandable="true"
class="mw-ui-input"
type="text"
- placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',LCRun3::ch($cx,
'plaintextSnippet', Array(Array(((is_array($in['content']) &&
isset($in['content']['format'])) ? $in['content']['format'] :
null),((is_array($in['content']) && isset($in['content']['content'])) ?
$in['content']['content'] : null)),Array()), 'raw')),Array()), 'encq').'"
+ placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',((is_array($in['properties'])
&& isset($in['properties']['topic-of-post'])) ?
$in['properties']['topic-of-post'] : null)),Array()), 'encq').'"
data-role="content">'.((LCRun3::ifvar($cx,
((is_array($cx['scopes'][0]) && isset($cx['scopes'][0]['submitted'])) ?
$cx['scopes'][0]['submitted'] : null))) ? ''.LCRun3::hbch($cx, 'ifCond',
Array(Array(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['postId'])) ?
$cx['scopes'][0]['submitted']['postId'] : null),'===',((is_array($in) &&
isset($in['postId'])) ? $in['postId'] : null)),Array()), $in, function($cx,
$in) {return ''.htmlentities(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['content'])) ?
$cx['scopes'][0]['submitted']['content'] : null), ENT_QUOTES, 'UTF-8').'';}).''
: '').'</textarea>
<div class="flow-form-actions flow-form-collapsible">
@@ -620,4 +619,4 @@
</div>
';
}
-?>
\ No newline at end of file
+?>
diff --git a/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
b/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
index a703e10..c83a57a 100644
--- a/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
+++ b/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
@@ -18,7 +18,6 @@
'concat' => 'Flow\TemplateHelper::concat',
'linkWithReturnTo' => 'Flow\TemplateHelper::linkWithReturnTo',
'escapeContent' => 'Flow\TemplateHelper::escapeContent',
- 'plaintextSnippet' => 'Flow\TemplateHelper::plaintextSnippet',
),
'blockhelpers' => Array(),
'hbhelpers' => Array( 'eachPost' =>
'Flow\TemplateHelper::eachPost',
@@ -578,7 +577,7 @@
data-flow-expandable="true"
class="mw-ui-input"
type="text"
- placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',LCRun3::ch($cx,
'plaintextSnippet', Array(Array(((is_array($in['content']) &&
isset($in['content']['format'])) ? $in['content']['format'] :
null),((is_array($in['content']) && isset($in['content']['content'])) ?
$in['content']['content'] : null)),Array()), 'raw')),Array()), 'encq').'"
+ placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',((is_array($in['properties'])
&& isset($in['properties']['topic-of-post'])) ?
$in['properties']['topic-of-post'] : null)),Array()), 'encq').'"
data-role="content">'.((LCRun3::ifvar($cx,
((is_array($cx['scopes'][0]) && isset($cx['scopes'][0]['submitted'])) ?
$cx['scopes'][0]['submitted'] : null))) ? ''.LCRun3::hbch($cx, 'ifCond',
Array(Array(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['postId'])) ?
$cx['scopes'][0]['submitted']['postId'] : null),'===',((is_array($in) &&
isset($in['postId'])) ? $in['postId'] : null)),Array()), $in, function($cx,
$in) {return ''.htmlentities(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['content'])) ?
$cx['scopes'][0]['submitted']['content'] : null), ENT_QUOTES, 'UTF-8').'';}).''
: '').'</textarea>
<div class="flow-form-actions flow-form-collapsible">
@@ -620,4 +619,4 @@
</div>
';
}
-?>
\ No newline at end of file
+?>
diff --git a/handlebars/compiled/flow_block_topiclist.handlebars.php
b/handlebars/compiled/flow_block_topiclist.handlebars.php
index 4a79dbf..c38eb9d 100644
--- a/handlebars/compiled/flow_block_topiclist.handlebars.php
+++ b/handlebars/compiled/flow_block_topiclist.handlebars.php
@@ -472,7 +472,7 @@
data-flow-expandable="true"
class="mw-ui-input"
type="text"
- placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',LCRun3::ch($cx,
'plaintextSnippet', Array(Array(((is_array($in['content']) &&
isset($in['content']['format'])) ? $in['content']['format'] :
null),((is_array($in['content']) && isset($in['content']['content'])) ?
$in['content']['content'] : null)),Array()), 'raw')),Array()), 'encq').'"
+ placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',((is_array($in['properties'])
&& isset($in['properties']['topic-of-post'])) ?
$in['properties']['topic-of-post'] : null)),Array()), 'encq').'"
data-role="content">'.((LCRun3::ifvar($cx,
((is_array($cx['scopes'][0]) && isset($cx['scopes'][0]['submitted'])) ?
$cx['scopes'][0]['submitted'] : null))) ? ''.LCRun3::hbch($cx, 'ifCond',
Array(Array(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['postId'])) ?
$cx['scopes'][0]['submitted']['postId'] : null),'===',((is_array($in) &&
isset($in['postId'])) ? $in['postId'] : null)),Array()), $in, function($cx,
$in) {return ''.htmlentities(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['content'])) ?
$cx['scopes'][0]['submitted']['content'] : null), ENT_QUOTES, 'UTF-8').'';}).''
: '').'</textarea>
<div class="flow-form-actions flow-form-collapsible">
@@ -550,7 +550,7 @@
data-flow-expandable="true"
class="mw-ui-input"
type="text"
- placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',LCRun3::ch($cx,
'plaintextSnippet', Array(Array(((is_array($in['content']) &&
isset($in['content']['format'])) ? $in['content']['format'] :
null),((is_array($in['content']) && isset($in['content']['content'])) ?
$in['content']['content'] : null)),Array()), 'raw')),Array()), 'encq').'"
+ placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',((is_array($in['properties'])
&& isset($in['properties']['topic-of-post'])) ?
$in['properties']['topic-of-post'] : null)),Array()), 'encq').'"
data-role="content">'.((LCRun3::ifvar($cx,
((is_array($cx['scopes'][0]) && isset($cx['scopes'][0]['submitted'])) ?
$cx['scopes'][0]['submitted'] : null))) ? ''.LCRun3::hbch($cx, 'ifCond',
Array(Array(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['postId'])) ?
$cx['scopes'][0]['submitted']['postId'] : null),'===',((is_array($in) &&
isset($in['postId'])) ? $in['postId'] : null)),Array()), $in, function($cx,
$in) {return ''.htmlentities(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['content'])) ?
$cx['scopes'][0]['submitted']['content'] : null), ENT_QUOTES, 'UTF-8').'';}).''
: '').'</textarea>
<div class="flow-form-actions flow-form-collapsible">
@@ -583,7 +583,7 @@
<a
href="'.htmlentities(((is_array($in['actions']['reply']) &&
isset($in['actions']['reply']['url'])) ? $in['actions']['reply']['url'] :
null), ENT_QUOTES, 'UTF-8').'"
title="'.htmlentities(((is_array($in['actions']['reply']) &&
isset($in['actions']['reply']['title'])) ? $in['actions']['reply']['title'] :
null), ENT_QUOTES, 'UTF-8').'"
class="flow-ui-input-replacement-anchor
mw-ui-input"
- >'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',LCRun3::ch($cx,
'plaintextSnippet', Array(Array(((is_array($in['content']) &&
isset($in['content']['format'])) ? $in['content']['format'] :
null),((is_array($in['content']) && isset($in['content']['content'])) ?
$in['content']['content'] : null)),Array()), 'raw')),Array()), 'encq').'</a>
+ >'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',((is_array($in['properties'])
&& isset($in['properties']['topic-of-post'])) ?
$in['properties']['topic-of-post'] : null)),Array()), 'encq').'</a>
';}).'
' : '').'
' : '').'
@@ -611,4 +611,4 @@
</div>
';
}
-?>
\ No newline at end of file
+?>
diff --git a/handlebars/compiled/flow_post.handlebars.php
b/handlebars/compiled/flow_post.handlebars.php
index 971b006..7b786d3 100644
--- a/handlebars/compiled/flow_post.handlebars.php
+++ b/handlebars/compiled/flow_post.handlebars.php
@@ -16,7 +16,6 @@
'l10nParse' => 'Flow\TemplateHelper::l10nParse',
'linkWithReturnTo' => 'Flow\TemplateHelper::linkWithReturnTo',
'escapeContent' => 'Flow\TemplateHelper::escapeContent',
- 'plaintextSnippet' => 'Flow\TemplateHelper::plaintextSnippet',
),
'blockhelpers' => Array(),
'hbhelpers' => Array( 'eachPost' =>
'Flow\TemplateHelper::eachPost',
@@ -545,7 +544,7 @@
data-flow-expandable="true"
class="mw-ui-input"
type="text"
- placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',LCRun3::ch($cx,
'plaintextSnippet', Array(Array(((is_array($in['content']) &&
isset($in['content']['format'])) ? $in['content']['format'] :
null),((is_array($in['content']) && isset($in['content']['content'])) ?
$in['content']['content'] : null)),Array()), 'raw')),Array()), 'encq').'"
+ placeholder="'.LCRun3::ch($cx, 'l10n',
Array(Array('flow-reply-topic-title-placeholder',((is_array($in['properties'])
&& isset($in['properties']['topic-of-post'])) ?
$in['properties']['topic-of-post'] : null)),Array()), 'encq').'"
data-role="content">'.((LCRun3::ifvar($cx,
((is_array($cx['scopes'][0]) && isset($cx['scopes'][0]['submitted'])) ?
$cx['scopes'][0]['submitted'] : null))) ? ''.LCRun3::hbch($cx, 'ifCond',
Array(Array(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['postId'])) ?
$cx['scopes'][0]['submitted']['postId'] : null),'===',((is_array($in) &&
isset($in['postId'])) ? $in['postId'] : null)),Array()), $in, function($cx,
$in) {return ''.htmlentities(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['content'])) ?
$cx['scopes'][0]['submitted']['content'] : null), ENT_QUOTES, 'UTF-8').'';}).''
: '').'</textarea>
<div class="flow-form-actions flow-form-collapsible">
@@ -583,4 +582,4 @@
';}).'
';
}
-?>
\ No newline at end of file
+?>
diff --git a/handlebars/flow_reply_form.handlebars
b/handlebars/flow_reply_form.handlebars
index 9be4162..7429135 100644
--- a/handlebars/flow_reply_form.handlebars
+++ b/handlebars/flow_reply_form.handlebars
@@ -20,7 +20,7 @@
data-flow-expandable="true"
class="mw-ui-input"
type="text"
- placeholder="{{l10n
"flow-reply-topic-title-placeholder" (plaintextSnippet content.format
content.content)}}"
+ placeholder="{{l10n
"flow-reply-topic-title-placeholder" properties.topic-of-post}}"
data-role="content">
{{~#if @root.submitted~}}
{{~#ifCond @root.submitted.postId "==="
postId~}}
diff --git a/handlebars/flow_topic.handlebars b/handlebars/flow_topic.handlebars
index 307ae0b..ab6d2e7 100644
--- a/handlebars/flow_topic.handlebars
+++ b/handlebars/flow_topic.handlebars
@@ -32,7 +32,7 @@
title="{{actions.reply.title}}"
class="flow-ui-input-replacement-anchor
mw-ui-input"
>
- {{~l10n
"flow-reply-topic-title-placeholder" (plaintextSnippet content.format
content.content)~}}
+ {{~l10n
"flow-reply-topic-title-placeholder" properties.topic-of-post~}}
</a>
{{/ifCond}}
{{/if}}
diff --git a/includes/Formatter/RevisionFormatter.php
b/includes/Formatter/RevisionFormatter.php
index 1f73fb3..2cce632 100644
--- a/includes/Formatter/RevisionFormatter.php
+++ b/includes/Formatter/RevisionFormatter.php
@@ -249,6 +249,18 @@
$row->revision->getCreatorId(),
$row->revision->getCreatorIp()
);
+
+ // Always output this along with topic titles so they
+ // have a safe parameter to use within l10n for content
+ // output.
+ if ( $row->revision->isTopicTitle() && !isset(
$res['properties']['topic-of-post'] ) ) {
+ $res['properties']['topic-of-post'] =
$this->processParam(
+ 'topic-of-post',
+ $row->revision,
+ $row->workflow->getId(),
+ $ctx
+ );
+ }
}
return $res;
diff --git a/modules/new/components/flow-board.js
b/modules/new/components/flow-board.js
index f44c60b..3b47d0d 100644
--- a/modules/new/components/flow-board.js
+++ b/modules/new/components/flow-board.js
@@ -1620,9 +1620,8 @@
name: author
},
// text for
flow-reply-topic-title-placeholder placeholder
- content: {
- content: replyToContent,
- format: 'plaintext'
+ properties: {
+ 'topic-of-post':
replyToContent.substr( 0, 200 ).trim()
}
}
) ).children();
--
To view, visit https://gerrit.wikimedia.org/r/162308
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1ce7a49304abe87ec663c193461def4ee053273d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: wmf/1.24wmf22
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits