renderer.article: Remove leading spaces before brackets

Bug: T69225
Change-Id: I83f79fa0ebd19bea6ed7ea266cece0778210adb2
This commit is contained in:
Prateek Saxena 2015-01-02 17:01:12 +05:30
parent df0b988eec
commit 3eaf2829e8
2 changed files with 11 additions and 1 deletions

View file

@ -210,6 +210,10 @@
continue;
}
if ( level === 0 ) {
// Remove leading spaces before brackets
if ( ch === ' ' && string.charAt( i + 1 ) === '(' ) {
continue;
}
newString += ch;
}
}

View file

@ -2,7 +2,7 @@
QUnit.module( 'ext.popups' );
QUnit.test( 'render.article.getProcessedElements', function ( assert ) {
QUnit.expect( 11 );
QUnit.expect( 12 );
function test ( extract, title, expected, msg ) {
var $div = $( '<div>' ).append(
@ -59,6 +59,12 @@
'Extract with unbalanced parentheses'
);
test(
'Vappu (born August 7), also known as Lexy', 'Vappu',
'<b>Vappu</b>, also known as Lexy',
'Spaces around bracketed text should be removed'
);
test(
'Epic XSS <script>alert("XSS")</script> is epic', 'Epic XSS',
'<b>Epic XSS</b> &lt;script&gt;alert&lt;/script&gt; is epic',