jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/381949 )

Change subject: MWImage: Fix js error when textchunk is \n with no tags
......................................................................


MWImage: Fix js error when textchunk is \n with no tags

Add a check for tags array before accessing.

Can be tested using the bin/adapt utility and the following html

<p id="mwAQ">
<figure class="mw-default-size mw-image-border" typeof="mw:Image/Frame" 
id="mwAQ">
<a href="./File:Example.jpg" id="mwAg">
<img resource="./File:Example.jpg" 
src="//upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg" id="mwAw"/></a>
<figcaption id="mwBA">caption</figcaption></figure>
</p>

Change-Id: I1f31ccfe940725bd9cde0d990df3851ad0a9eb15
---
M lib/translationunits/MWImage.js
1 file changed, 1 insertion(+), 1 deletion(-)

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



diff --git a/lib/translationunits/MWImage.js b/lib/translationunits/MWImage.js
index 1d7dce9..d99903a 100644
--- a/lib/translationunits/MWImage.js
+++ b/lib/translationunits/MWImage.js
@@ -56,7 +56,7 @@
 
        for ( i = 0, len = this.node.children.textChunks.length; i < len; i++ ) 
{
                chunk = this.node.children.textChunks[ i ];
-               if ( chunk.tags[ 0 ].name === 'a' ) {
+               if ( chunk.tags[ 0 ] && chunk.tags[ 0 ].name === 'a' ) {
                        imageLink = chunk.tags[ 0 ];
                }
                if ( chunk.inlineContent && chunk.inlineContent.name === 'img' 
) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1f31ccfe940725bd9cde0d990df3851ad0a9eb15
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>
Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to