Fix error on a redirect page with no link
https://lists.sr.ht/~cadence/breezewiki-discuss/%3CCY2G0E3G55N3.ANW2QREUS5SO%40nixnetmail.com%3E
This commit is contained in:
		
							parent
							
								
									723bb92b0a
								
							
						
					
					
						commit
						3942350468
					
				
					 2 changed files with 12 additions and 6 deletions
				
			
		|  | @ -98,16 +98,19 @@ | ||||||
|          #:head-data head-data |          #:head-data head-data | ||||||
|          #:siteinfo (siteinfo-fetch wikiname) |          #:siteinfo (siteinfo-fetch wikiname) | ||||||
|          )) |          )) | ||||||
|       (define redirect-msg ((query-selector (attribute-selector 'class "redirectMsg") body))) |  | ||||||
|       (define redirect-query-parameter (dict-ref (url-query (request-uri req)) 'redirect "yes")) |       (define redirect-query-parameter (dict-ref (url-query (request-uri req)) 'redirect "yes")) | ||||||
|  |       (define redirect-msg ((query-selector (attribute-selector 'class "redirectMsg") body))) | ||||||
|  |       (define redirect-msg-a (if redirect-msg | ||||||
|  |                                  ((query-selector (λ (t a c) (eq? t 'a)) redirect-msg)) | ||||||
|  |                                  #f)) | ||||||
|       (define headers |       (define headers | ||||||
|         (build-headers |         (build-headers | ||||||
|          always-headers |          always-headers | ||||||
|          ; redirect-query-parameter: only the string "no" is significant: |          ; redirect-query-parameter: only the string "no" is significant: | ||||||
|          ; https://github.com/Wikia/app/blob/fe60579a53f16816d65dad1644363160a63206a6/includes/Wiki.php#L367 |          ; https://github.com/Wikia/app/blob/fe60579a53f16816d65dad1644363160a63206a6/includes/Wiki.php#L367 | ||||||
|          (when (and redirect-msg |          (when (and redirect-msg-a | ||||||
|                     (not (equal? redirect-query-parameter "no"))) |                     (not (equal? redirect-query-parameter "no"))) | ||||||
|            (let* ([dest (get-attribute 'href (bits->attributes ((query-selector (λ (t a c) (eq? t 'a)) redirect-msg))))] |            (let* ([dest (get-attribute 'href (bits->attributes redirect-msg-a))] | ||||||
|                   [value (bytes-append #"0;url=" (string->bytes/utf-8 dest))]) |                   [value (bytes-append #"0;url=" (string->bytes/utf-8 dest))]) | ||||||
|              (header #"Refresh" value))))) |              (header #"Refresh" value))))) | ||||||
|       (when (config-true? 'debug) |       (when (config-true? 'debug) | ||||||
|  |  | ||||||
|  | @ -80,16 +80,19 @@ | ||||||
|                #:title title |                #:title title | ||||||
|                #:head-data head-data |                #:head-data head-data | ||||||
|                #:siteinfo siteinfo)) |                #:siteinfo siteinfo)) | ||||||
|             (define redirect-msg ((query-selector (attribute-selector 'class "redirectMsg") body))) |  | ||||||
|             (define redirect-query-parameter (dict-ref (url-query (request-uri req)) 'redirect "yes")) |             (define redirect-query-parameter (dict-ref (url-query (request-uri req)) 'redirect "yes")) | ||||||
|  |             (define redirect-msg ((query-selector (attribute-selector 'class "redirectMsg") body))) | ||||||
|  |             (define redirect-msg-a (if redirect-msg | ||||||
|  |                                        ((query-selector (λ (t a c) (eq? t 'a)) redirect-msg)) | ||||||
|  |                                        #f)) | ||||||
|             (define headers |             (define headers | ||||||
|               (build-headers |               (build-headers | ||||||
|                always-headers |                always-headers | ||||||
|                ; redirect-query-parameter: only the string "no" is significant: |                ; redirect-query-parameter: only the string "no" is significant: | ||||||
|                ; https://github.com/Wikia/app/blob/fe60579a53f16816d65dad1644363160a63206a6/includes/Wiki.php#L367 |                ; https://github.com/Wikia/app/blob/fe60579a53f16816d65dad1644363160a63206a6/includes/Wiki.php#L367 | ||||||
|                (when (and redirect-msg |                (when (and redirect-msg-a | ||||||
|                           (not (equal? redirect-query-parameter "no"))) |                           (not (equal? redirect-query-parameter "no"))) | ||||||
|                  (let* ([dest (get-attribute 'href (bits->attributes ((query-selector (λ (t a c) (eq? t 'a)) redirect-msg))))] |                  (let* ([dest (get-attribute 'href (bits->attributes redirect-msg-a))] | ||||||
|                         [value (bytes-append #"0;url=" (string->bytes/utf-8 dest))]) |                         [value (bytes-append #"0;url=" (string->bytes/utf-8 dest))]) | ||||||
|                    (header #"Refresh" value))))) |                    (header #"Refresh" value))))) | ||||||
|             (when (config-true? 'debug) |             (when (config-true? 'debug) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue