jenkins-bot has submitted this change and it was merged.

Change subject: Don't let headings be HTML
......................................................................


Don't let headings be HTML

Bug: 50125
Change-Id: I39c3856c904333ae121a9fe7cf89e02b1df889ea
---
M javascripts/common/PageApi.js
M tests/javascripts/common/test_PageApi.js
2 files changed, 17 insertions(+), 0 deletions(-)

Approvals:
  JGonera: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/javascripts/common/PageApi.js b/javascripts/common/PageApi.js
index 2ef8c2f..4ee50f8 100644
--- a/javascripts/common/PageApi.js
+++ b/javascripts/common/PageApi.js
@@ -8,6 +8,8 @@
                        result = [], $tmpContainer = $( '<div>' );
 
                $.each( sections, function( i, section ) {
+                       // FIXME: [API] should probably do this for us - we 
want to be able to control the styling of these headings - no inline styles!
+                       section.line = $( '<div>' ).html( section.line ).text();
                        if ( !section.level || section.level === collapseLevel 
) {
                                result.push( section );
                        } else {
diff --git a/tests/javascripts/common/test_PageApi.js 
b/tests/javascripts/common/test_PageApi.js
index 37d0cd4..a28f30d 100644
--- a/tests/javascripts/common/test_PageApi.js
+++ b/tests/javascripts/common/test_PageApi.js
@@ -227,4 +227,19 @@
                pageApi._getAllLanguages.restore();
        } );
 
+       QUnit.test( '#getPage (html headings get stripped)', 1, function( 
assert ) {
+               sinon.stub( PageApi.prototype, 'get' ).returns( 
$.Deferred().resolve( {
+                       "mobileview": {
+                               "sections":[
+                                       {"id":0,"text":""},
+                                       {"level":"1","line":"<i>html text 
heading</i>","anchor":"1","id":1,"text":"<p>Text of 1\n</p>"}
+                               ]
+                       }
+               } ) );
+               pageApi.getPage( 'Test' ).done( function( resp ) {
+                       assert.strictEqual( resp.sections[0].line, 'html text 
heading' );
+               } );
+               PageApi.prototype.get.restore();
+       } );
+
 }( mw.mobileFrontend, jQuery ) );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I39c3856c904333ae121a9fe7cf89e02b1df889ea
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to