GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • View File
  • Edit File
  • Delete File
  • View Transforms
  • Details

This view

  • Original page
  • New address

GeezerVison is showing phabricator.wikimedia.org — ⇪ preSaveTransform-diff.txt

Page MenuHomePhabricator
Log In
Files F2122

preSaveTransform-diff.txt
Public
Actions

  • View File
  • Edit File
  • Delete File
  • View Transforms
Authored By
• bzimport
Nov 21 2014, 8:36 PM2014-11-21 20:36:06 (UTC+0)
Size
3 KB
Referenced Files
None
Subscribers
None

preSaveTransform-diff.txt
View Options

diff --git a/includes/parser/CoreTagHooks.php b/includes/parser/CoreTagHooks.php
index 7d488c4..6c33cd5 100644
--- a/includes/parser/CoreTagHooks.php
+++ b/includes/parser/CoreTagHooks.php
@@ -18,7 +18,7 @@ class CoreTagHooks {
global $wgRawHtml;
$parser->setHook( 'pre', array( __CLASS__, 'pre' ) );
$parser->setHook( 'nowiki', array( __CLASS__, 'nowiki' ) );
- $parser->setHook( 'gallery', array( __CLASS__, 'gallery' ) );
+ $parser->setHook( 'gallery', array( __CLASS__, 'gallery' ) , array('preSaveTrans' => true) );
if ( $wgRawHtml ) {
$parser->setHook( 'html', array( __CLASS__, 'html' ) );
}
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 20c8b95..3510d44 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -106,6 +106,7 @@ class Parser {
var $mFunctionTagHooks = array();
var $mStripList = array();
var $mDefaultStripList = array();
+ var $mPstAcceptableXmlTags = array();
var $mVarCache = array();
var $mImageParams = array();
var $mImageParamsMagicArray = array();
@@ -181,6 +182,11 @@ class Parser {
var $mUniqPrefix;
/**
+ * @var string
+ */
+ var $mDuringPreSaveTransform = false;
+
+ /**
* Constructor
*
* @param $conf array
@@ -845,7 +851,11 @@ class Parser {
* @return array
*/
function getStripList() {
- return $this->mStripList;
+ if ( $this->mDuringPreSaveTransform ) {
+ return $this->mStripList;
+ } else {
+ return array_merge($this->mStripList, $this->mPstAcceptableXmlTags);
+ }
}
/**
@@ -4303,6 +4313,8 @@ class Parser {
public function preSaveTransform( $text, Title $title, User $user, ParserOptions $options, $clearState = true ) {
$this->startParse( $title, $options, self::OT_WIKI, $clearState );
$this->setUser( $user );
+
+ $this->mDuringPreSaveTransform = true;
$pairs = array(
"\r\n" => "\n",
@@ -4314,6 +4326,8 @@ class Parser {
$text = $this->mStripState->unstripBoth( $text );
$this->setUser( null ); #Reset
+
+ $this->mDuringPreSaveTransform = false;
return $text;
}
@@ -4609,16 +4623,21 @@ class Parser {
* @param $callback Mixed: the callback function (and object) to use for the tag
* @return Mixed|null The old value of the mTagHooks array associated with the hook
*/
- public function setHook( $tag, $callback ) {
+ public function setHook( $tag, $callback, $options = array() ) {
$tag = strtolower( $tag );
if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) {
throw new MWException( "Invalid character {$m[0]} in setHook('$tag', ...) call" );
}
$oldVal = isset( $this->mTagHooks[$tag] ) ? $this->mTagHooks[$tag] : null;
$this->mTagHooks[$tag] = $callback;
- if ( !in_array( $tag, $this->mStripList ) ) {
- $this->mStripList[] = $tag;
- }
+
+ if ( isset($options['preSaveTrans']) && $options['preSaveTrans'] === true ) {
+ if ( !in_array( $tag, $this->mPstAcceptableXmlTags ) ) {
+ $this->mPstAcceptableXmlTags[] = $tag;
+ }
+ } elseif ( !in_array( $tag, $this->mStripList ) ) {
+ $this->mStripList[] = $tag;
+ }
return $oldVal;
}
@@ -4657,6 +4676,8 @@ class Parser {
$this->mTagHooks = array();
$this->mFunctionTagHooks = array();
$this->mStripList = $this->mDefaultStripList;
+ $this->mPstAcceptableXmlTags = array();
+ $this->mDuringPreSaveTransform = false;
}
/**

File Metadata

  • Details
  • Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1699
Default Alt Text
preSaveTransform-diff.txt (3 KB)
Attached ToMode
T4700: Pre-save transform skips extensions using wikitext (gallery, references, footnotes, Cite, status indicators, pipe trick, subst, signatures)Attached
Detach File

Event Timeline

Log In to Comment
Content licensed under Creative Commons Attribution-ShareAlike (CC BY-SA) 4.0 unless otherwise noted; code licensed under GNU General Public License (GPL) 2.0 or later and other open source licenses. By using this site, you agree to the Terms of Use, Privacy Policy, and Code of Conduct. · Wikimedia Foundation · Privacy Policy · Code of Conduct · Terms of Use · Disclaimer · CC-BY-SA · GPL · Credits
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.