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

Change subject: Removed some dead code in the LinkHandler
......................................................................


Removed some dead code in the LinkHandler

* linkData.type is being normalized to mw:ExtLink in
  getLinkRoundTripData.

* In addition, ensure that linkData.type only sets
  Parsoid-recognized link types and defaults to ExtLink
  for everything else.

* Logging with a fatal/request should catch anything else.

Change-Id: Id9a32170b94107134bfb209be7669c22115a8ddb
---
M lib/wts.LinkHandler.js
1 file changed, 11 insertions(+), 19 deletions(-)

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



diff --git a/lib/wts.LinkHandler.js b/lib/wts.LinkHandler.js
index 473ec26..30975bb 100644
--- a/lib/wts.LinkHandler.js
+++ b/lib/wts.LinkHandler.js
@@ -84,7 +84,10 @@
        // Figure out the type of the link
        var rel = node.getAttribute('rel');
        if ( rel ) {
-               var typeMatch = rel.match( /(?:^|\s)(mw:[^\s]+)/ );
+               // Parsoid only emits and recognizes ExtLink, WikiLink, and 
PageProp rel values.
+               // Everything else defaults to ExtLink during serialization 
(unless it is
+               // serializable to a wikilink)
+               var typeMatch = rel.match( 
/\b(mw:(?:WikiLink|ExtLink|PageProp)[^\s]*)\b/ );
                if ( typeMatch ) {
                        rtData.type = typeMatch[1];
                        // Strip link subtype info
@@ -94,7 +97,7 @@
                }
        }
 
-       // Default type
+       // Default link type if nothing else is set
        if (rtData.type === null && !node.querySelector('IMG')) {
                rtData.type = 'mw:ExtLink';
        }
@@ -609,30 +612,19 @@
                }
 
                if (/^mw:WikiLink$/.test(linkData.type) || 
Util.solTransparentLinkRegexp.test(linkData.type)) {
+                       // [[..]] links: normal, category, redirect, or lang 
links (except images)
                        serializeAsWikiLink(node, state, linkData, cb);
                } else if ( linkData.type === 'mw:ExtLink' ) {
+                       // [..] links, ISBN, RFC, PMID
                        serializeAsExtLink(node, state, linkData, href, cb);
-               } else if ( linkData.type.match( /mw:ExtLink\/(?:RFC|PMID)/ ) ||
-                                       
/mw:(?:Wiki|Ext)Link\/ISBN/.test(node.getAttribute('rel') || '') ) {
-                       // FIXME: Handle RFC/PMID in generic ExtLink handler by 
matching prefixes!
-                       // FIXME: Handle ISBN in generic WikiLink handler by 
looking for
-                       // Special:BookSources!
-                       cb( new MagicLinkText( node.firstChild.nodeValue, node 
), node );
-                       return;
                } else if ( /(?:^|\s)mw:Image/.test(linkData.type) ) {
                        this.handleImage( node, state, cb );
-                       return;
                } else {
-                       // Unknown rel was set
-                       if (target.modified || !target.fromsrc) {
-                               target.value = escapeExtLinkURL(target.value);
-                       }
-                       cb( new ExtLinkText(
-                               '[' + target.value + ' ' +
-                               state.serializeLinkChildrenToString(node, 
this.wteHandlers.aHandler, false) +
-                               ']', node, wiki, linkData.type ), node );
-                       return;
+                       env.log("fatal/request",
+                               "Unhandled link serialization scenario:",
+                               node.outerHTML);
                }
+               return;
        } else {
                var safeAttr = new Set(["href", "rel", "class", "title"]);
                var isComplexLink = function ( attributes ) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id9a32170b94107134bfb209be7669c22115a8ddb
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <ssas...@wikimedia.org>
Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org>
Gerrit-Reviewer: Cscott <canan...@wikimedia.org>
Gerrit-Reviewer: Marcoil <marc...@wikimedia.org>
Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org>
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