summaryrefslogtreecommitdiff
path: root/includes/OutputPage.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/OutputPage.php')
-rw-r--r--includes/OutputPage.php73
1 files changed, 45 insertions, 28 deletions
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index 6bfba78b..363f2b62 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -151,12 +151,12 @@ class OutputPage extends ContextSource {
var $mFeedLinksAppendQuery = null;
- # What level of 'untrustworthiness' is allowed in CSS/JS modules loaded on this page?
- # @see ResourceLoaderModule::$origin
- # ResourceLoaderModule::ORIGIN_ALL is assumed unless overridden;
- protected $mAllowedModules = array(
- ResourceLoaderModule::TYPE_COMBINED => ResourceLoaderModule::ORIGIN_ALL,
- );
+ /**
+ * @var int
+ * The level of 'untrustworthiness' allowed for modules loaded on this page.
+ * @see ResourceLoaderModule::$origin
+ */
+ protected $mAllowedModuleOrigin = ResourceLoaderModule::ORIGIN_ALL;
/**
* @EasterEgg I just love the name for this self documenting variable.
@@ -1271,14 +1271,13 @@ class OutputPage extends ContextSource {
}
/**
- * Do not allow scripts which can be modified by wiki users to load on this page;
- * only allow scripts bundled with, or generated by, the software.
+ * Restrict the page to loading modules bundled the software.
+ *
+ * Disallows the queue to contain any modules which can be modified by wiki
+ * users to load on this page.
*/
public function disallowUserJs() {
- $this->reduceAllowedModules(
- ResourceLoaderModule::TYPE_SCRIPTS,
- ResourceLoaderModule::ORIGIN_CORE_INDIVIDUAL
- );
+ $this->reduceAllowedModuleOrigin( ResourceLoaderModule::ORIGIN_CORE_INDIVIDUAL );
}
/**
@@ -1293,37 +1292,55 @@ class OutputPage extends ContextSource {
}
/**
- * Show what level of JavaScript / CSS untrustworthiness is allowed on this page
+ * Get the level of JavaScript / CSS untrustworthiness allowed on this page.
+ *
* @see ResourceLoaderModule::$origin
- * @param string $type ResourceLoaderModule TYPE_ constant
+ * @param string $type Unused: Module origin allowance used to be fragmented by
+ * ResourceLoaderModule TYPE_ constants.
* @return Int ResourceLoaderModule ORIGIN_ class constant
*/
- public function getAllowedModules( $type ) {
- if ( $type == ResourceLoaderModule::TYPE_COMBINED ) {
- return min( array_values( $this->mAllowedModules ) );
- } else {
- return isset( $this->mAllowedModules[$type] )
- ? $this->mAllowedModules[$type]
- : ResourceLoaderModule::ORIGIN_ALL;
- }
+ public function getAllowedModules( $type = null ) {
+ return $this->mAllowedModuleOrigin;
}
/**
* Set the highest level of CSS/JS untrustworthiness allowed
+ *
+ * @deprecated since 1.24 Raising level of allowed untrusted content is no longer supported.
+ * Use reduceAllowedModuleOrigin() instead.
+ *
* @param $type String ResourceLoaderModule TYPE_ constant
- * @param $level Int ResourceLoaderModule class constant
+ * @param int $level ResourceLoaderModule ORIGIN_ constant
*/
public function setAllowedModules( $type, $level ) {
- $this->mAllowedModules[$type] = $level;
+ wfDeprecated( __METHOD__, '1.24' );
+ $this->reduceAllowedModuleOrigin( $level );
}
/**
- * As for setAllowedModules(), but don't inadvertently make the page more accessible
- * @param $type String
- * @param $level Int ResourceLoaderModule class constant
+ * Limit the highest level of CSS/JS untrustworthiness allowed.
+ *
+ * @deprecated since 1.24 Module allowance is no longer fragmented by content type.
+ * Use reduceAllowedModuleOrigin() instead.
+ *
+ * @param string $type ResourceLoaderModule TYPE_ constant
+ * @param int $level ResourceLoaderModule ORIGIN_ class constant
*/
public function reduceAllowedModules( $type, $level ) {
- $this->mAllowedModules[$type] = min( $this->getAllowedModules( $type ), $level );
+ wfDeprecated( __METHOD__, '1.24' );
+ $this->reduceAllowedModuleOrigin( $level );
+ }
+
+ /**
+ * Limit the highest level of CSS/JS untrustworthiness allowed.
+ *
+ * If passed the same or a higher level than the current level of untrustworthiness set, the
+ * level will remain unchanged.
+ *
+ * @param int $level ResourceLoaderModule class constant
+ */
+ public function reduceAllowedModuleOrigin( $level ) {
+ $this->mAllowedModuleOrigin = min( $this->mAllowedModuleOrigin, $level );
}
/**