Catrope has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/378823 )
Change subject: [BREAKING CHANGE] Return full HTML document in segmentedContent ...................................................................... [BREAKING CHANGE] Return full HTML document in segmentedContent This endpoint only returned the <body> previously, using hacky code to do so. However, the full document is valuable for VisualEditor, especially because of the <base> tag. Instead of stripping the HTML on the server, send the full HTML to the client so it has a chance to look at the header data before extracting the body. Depends-On: Id6235710eaec77f8d9b3eef8abf6c5f838d9b2d4 Change-Id: I8367f9f27642a38104d7999c4f32b9bc7a3bc412 --- M lib/pageloader/PageLoader.js 1 file changed, 1 insertion(+), 22 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver refs/changes/23/378823/1 diff --git a/lib/pageloader/PageLoader.js b/lib/pageloader/PageLoader.js index dde851a..9c7ed10 100644 --- a/lib/pageloader/PageLoader.js +++ b/lib/pageloader/PageLoader.js @@ -2,27 +2,6 @@ var apiUtil = require( '../api-util' ); -/** - * Cheap body extraction. - * - * This is safe as we know that the HTML we are receiving from Parsoid is - * serialized as XML. - * Restbase does not support body only retrieval of content. - * See https://phabricator.wikimedia.org/T95199 - * - * @param {string} html - * @return {string} body of the html passed, wrapped in <body> tag. - */ -function cheapBodyInnerHTML( html ) { - var match = /<body[^>]*>([\s\S]*)<\/body>/.exec( html ); - - if ( !match ) { - throw new Error( 'No HTML body found!' ); - } else { - return '<body>' + match[ 1 ] + '</body>'; - } -} - function PageLoader( app ) { this.app = app; this.log = app.logger.log || function () {}; @@ -60,7 +39,7 @@ return apiUtil.restApiGet( this.app, domain, path, restReq ).then( function ( response ) { return { - body: cheapBodyInnerHTML( response.body ), + body: response.body, // Restbase returns revision ID in etag header. // Example: // ETag: "123456/c4e494da-ee8f-11e4-83a1-8b80de1cde5f" -- To view, visit https://gerrit.wikimedia.org/r/378823 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8367f9f27642a38104d7999c4f32b9bc7a3bc412 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/cxserver Gerrit-Branch: master Gerrit-Owner: Catrope <r...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits