Jdlrobson has uploaded a new change for review.

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


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, 16 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/75/90075/1

diff --git a/javascripts/common/PageApi.js b/javascripts/common/PageApi.js
index 2ef8c2f..e7154ca 100644
--- a/javascripts/common/PageApi.js
+++ b/javascripts/common/PageApi.js
@@ -8,6 +8,7 @@
                        result = [], $tmpContainer = $( '<div>' );
 
                $.each( sections, function( i, section ) {
+                       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: newchange
Gerrit-Change-Id: I39c3856c904333ae121a9fe7cf89e02b1df889ea
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

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

Reply via email to