MaxSem has uploaded a new change for review.

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

Change subject: Remove inline styling
......................................................................

Remove inline styling

Change-Id: Ic19226b7ee9667cfafb4ab31fb8041144a249d88
---
M includes/Tag/MapLink.php
M includes/Tag/TagHandler.php
M tests/parserTests.txt
3 files changed, 6 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Kartographer 
refs/changes/27/292627/1

diff --git a/includes/Tag/MapLink.php b/includes/Tag/MapLink.php
index 732304c..1222eaa 100644
--- a/includes/Tag/MapLink.php
+++ b/includes/Tag/MapLink.php
@@ -35,11 +35,12 @@
                }
                $text = $this->parser->recursiveTagParse( $text, $this->frame );
                $style = $this->extractMarkerCss();
+               $attrs = $this->getDefaultAttributes();
 
-               $attrs = $this->getDefaultAttributes( $style );
                $attrs['class'] .= ' mw-kartographer-link';
                if ( $style ) {
                        $attrs['class'] .= ' mw-kartographer-autostyled';
+                       $attrs['style'] = $style;
                }
                if ( $this->cssClass !== '' ) {
                        $attrs['class'] .= ' ' . $this->cssClass;
diff --git a/includes/Tag/TagHandler.php b/includes/Tag/TagHandler.php
index 1b89c6c..7c07d62 100644
--- a/includes/Tag/TagHandler.php
+++ b/includes/Tag/TagHandler.php
@@ -49,9 +49,6 @@
        /** @var string */
        protected $mapStyle;
 
-       /** @var string */
-       protected $style = '';
-
        /** @var string name of the group, or null for private */
        protected $groupName;
 
@@ -158,21 +155,14 @@
                $this->zoom = $this->getInt( 'zoom' );
                $regexp = '/^(' . implode( '|', $wgKartographerStyles ) . ')$/';
                $this->mapStyle = $this->getText( 'mapstyle', 
$wgKartographerDfltStyle, $regexp );
-               $this->style = Sanitizer::checkCss( trim( $this->getText( 
'style', '' ) ) );
        }
 
        /**
         * Returns default HTML attributes of the outermost tag of the output
-        * @param string $extraStyle
         * @return string[]
         */
-       protected function getDefaultAttributes( $extraStyle = '' ) {
-               $attrs = [ 'class' => 'mw-kartographer', 'mw-data' => 
'interface' ];
-               $style = trim( "{$extraStyle} {$this->style}" );
-               if ( $style ) {
-                       $attrs['style'] = $style;
-               }
-               return $attrs;
+       protected function getDefaultAttributes() {
+               return [ 'class' => 'mw-kartographer', 'mw-data' => 'interface' 
];
        }
 
        /**
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 613e744..15eab50 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -184,11 +184,9 @@
 !! test
 CSS sanitization
 !! input
-<maplink latitude=10 longitude=20 zoom=10 style="color: red;" text="<span 
style='color: red;'&gt;foo</span&gt;"/>
-<maplink latitude=10 longitude=20 zoom=10 style="foo: bar; background-image: 
url(https://example.com);" text="<span style='foo: bar; background-image: 
url(https://example.com);'&gt;foo</span&gt;"/>
+<maplink latitude=10 longitude=20 zoom=10 style="color: red;" text="<span 
style='foo: bar; background-image: 
url(https://example.com);'&gt;foo</span&gt;"/><!-- style=... was removed -->
 !! result
-<p><a class="mw-kartographer mw-kartographer-link" mw-data="interface" 
style="color: red;" data-style="osm-intl" data-zoom="10" data-lat="10" 
data-lon="20"><span style="color: red;">foo</span></a>
-<a class="mw-kartographer mw-kartographer-link" mw-data="interface" style="/* 
insecure input */" data-style="osm-intl" data-zoom="10" data-lat="10" 
data-lon="20"><span style="/* insecure input */">foo</span></a>
+<p><a class="mw-kartographer mw-kartographer-link" mw-data="interface" 
data-style="osm-intl" data-zoom="10" data-lat="10" data-lon="20"><span 
style="/* insecure input */">foo</span></a>
 </p>
 !! end
 
@@ -228,23 +226,8 @@
        }
 }
 ]</maplink>
-
-<maplink latitude=10 longitude=20 zoom=13 style="border: yellow;">
-{
-"type": "Feature",
-       "geometry": {
-               "type": "Point",
-               "coordinates": [-122.3988, 37.8013]
-       },
-       "properties": {
-               "marker-symbol": "-number",
-               "marker-color": "FFF"
-       }
-}
-</maplink>
 !! result
 <p><a class="mw-kartographer mw-kartographer-link mw-kartographer-autostyled" 
mw-data="interface" style="background: #abcdef;" data-style="osm-intl" 
data-zoom="13" data-lat="10" data-lon="20" 
data-overlays="[&quot;_0d28e3b8954f29b4a6af62bd43a9cacc70ce0261&quot;]">A</a>
-</p><p><a class="mw-kartographer mw-kartographer-link 
mw-kartographer-autostyled" mw-data="interface" style="background: #FFF; 
border: yellow;" data-style="osm-intl" data-zoom="13" data-lat="10" 
data-lon="20" 
data-overlays="[&quot;_665bb76cf5c33a0a86108f17819b1c68d26a7ba7&quot;]">2</a>
 </p>
 !! end
 

-- 
To view, visit https://gerrit.wikimedia.org/r/292627
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic19226b7ee9667cfafb4ab31fb8041144a249d88
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Kartographer
Gerrit-Branch: master
Gerrit-Owner: MaxSem <maxsem.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to