[Libreoffice-commits] core.git: swext/mediawiki

Julien Nabet serval2412 at yahoo.fr
Sat Jun 10 21:02:36 UTC 2017


 swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java |   15 ++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

New commits:
commit e34b02834b24be4062ffd535aa1b929481ff427e
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sat Jun 10 10:45:23 2017 +0200

    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 <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

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 );
                     }
                 }
             }


More information about the Libreoffice-commits mailing list