From e34b02834b24be4062ffd535aa1b929481ff427e Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Sat, 10 Jun 2017 10:45:23 +0200 Subject: tdf#97743: mediawiki account To find main url in header section, search link containing: - load.php - or opensearch_desc.php In Wikipedia or wiki.documentfoundation.org, I haven't seen any link with index.php Change-Id: Iccb27aa8aaaf936faf8ec3b3f67eaa98d0426f19 Reviewed-on: https://gerrit.libreoffice.org/38631 Tested-by: Jenkins Reviewed-by: Julien Nabet --- swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'swext') diff --git a/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java b/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java index 4ef08950c11b..114709fae36e 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java +++ b/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java @@ -103,13 +103,16 @@ public class EditPageParser extends HTMLEditorKit.ParserCallback String sName = ( String ) a.getAttribute( HTML.Attribute.HREF ); if ( sName != null ) { - int nIndexStart = sName.indexOf( "index.php" ); - // get the main URL from the first header-link with index.php - // the link with "action=edit" inside is preferable - if ( nIndexStart>= 0 - && ( m_sMainURL.length() == 0 || sName.contains("action=edit") ) ) + // get the main URL from the first header-link with load.php (which is used for stylesheet) + int nPhpFileStart = sName.indexOf( "load.php" ); + if (nPhpFileStart < 0) + // if not found, try header-link with opensearch_desc.php + nPhpFileStart = sName.indexOf( "opensearch_desc.php" ); + + if ( nPhpFileStart >= 0 + && m_sMainURL.length() == 0 ) { - m_sMainURL = sName.substring( 0, nIndexStart ); + m_sMainURL = sName.substring( 0, nPhpFileStart ); } } } -- cgit v1.2.3