www-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

www/server/source/linc linc.py


From: Pavel Kharitonov
Subject: www/server/source/linc linc.py
Date: Mon, 02 May 2016 15:30:19 +0000

CVSROOT:        /web/www
Module name:    www
Changes by:     Pavel Kharitonov <ineiev>       16/05/02 15:30:18

Modified files:
        server/source/linc: linc.py 

Log message:
        Fix forwards with redirection like /new/path RT #1106119.

CVSWeb URLs:
http://web.cvs.savannah.gnu.org/viewcvs/www/server/source/linc/linc.py?cvsroot=www&r1=1.29&r2=1.30

Patches:
Index: linc.py
===================================================================
RCS file: /web/www/www/server/source/linc/linc.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- linc.py     15 Feb 2016 10:05:46 -0000      1.29
+++ linc.py     2 May 2016 15:30:17 -0000       1.30
@@ -3,7 +3,7 @@
 #
 # LINC - LINC Is Not Checklink
 # Copyright © 2011, 2012 Wacław Jacek
-# Copyright © 2013, 2014, 2015 Free Software Foundation, Inc.
+# Copyright © 2013, 2014, 2015, 2016 Free Software Foundation, Inc.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,13 +20,13 @@
 
 from __future__ import print_function
 
-LINC_VERSION = 'LINC 0.25'
+LINC_VERSION = 'LINC 0.26'
 USAGE = \
 '''Usage: %prog [options] [BASE_DIRECTORY]
 Check links in HTML files from BASE_DIRECTORY.'''
 COPYRIGHT= \
 '''Copyright (C) 2011, 2012 Waclaw Jacek
-Copyright (C) 2013, 2014, 2015 Free Software Foundation, Inc.
+Copyright (C) 2013, 2014, 2015, 2016 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.
@@ -243,7 +243,8 @@
                report(1, '- - - - -')
                return 'couldn\'t find end of ' \
                        + 'headers (possibly no content in file)'
-
+       match = re.search ('(?P<site>^[^/]*//[^/]+/)', link)
+       site = match.group('site')
        header = webpage[:end_of_headers]
        page = webpage[end_of_headers + len(EOH_MARK):]
        verb_level = 5
@@ -267,7 +268,7 @@
                if not match:
                        return None
                new_location = match.group('new_location')
-               [link_type, url] = classify_link("", new_location)
+               [link_type, url] = classify_link ("", new_location, None, site)
                if url == link:
                        # Refesh to the same URL.
                        return None
@@ -283,7 +284,7 @@
                                exit(1)
                        return None
                new_location = match.group('new_location')
-       [link_type, url] = classify_link("", new_location)
+       [link_type, url] = classify_link ("", new_location, None, site)
        return get_http_link_error(url, link_type, forwarded_from)
 
 def is_inside_comment(head):
@@ -326,12 +327,14 @@
                        + dest + "' <- `" + source + "' found.")
                symlinks[directory][source] = { 'dest': dest, 'line': i + 1 }
 
-def classify_link(filename, link, symlink = None):
+def classify_link(filename, link, symlink = None, remote_site = None):
        link_type = 'http'
        # When we process a symlinked file, we use the directory
        # from which it is linked rather than the actual location
        # of the file.
        dir_name = symlink if (symlink != None) else filename
+       if remote_site == None:
+               remote_site = remote_site_root
        if re.search('^(mailto:|irc://|rsync://)', link):
                link_type = 'unsupported'
        elif link.find('http://') == 0:
@@ -347,7 +350,7 @@
                else:
                        link_type = 'https'
        elif link[0] == '/':
-               link = remote_site_root + link[1:]
+               link = remote_site + link[1:]
        else:
                subdir = ''
                pos = dir_name.rfind('/')



reply via email to

[Prev in Thread] Current Thread [Next in Thread]