git: 5ab82f33cb - main - Firefox opensearch autocomplete workarounds

Wolfram Schneider <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.doc
Message-ID <[email protected]>
The branch main has been updated by wosch:

URL: https://cgit.FreeBSD.org/doc/commit/?id=5ab82f33cb9e28f730881431252cae8a4ab4a2bd

commit 5ab82f33cb9e28f730881431252cae8a4ab4a2bd
Author:     Wolfram Schneider <[email protected]>
AuthorDate: 2023-01-04 17:34:40 +0000
Commit:     Wolfram Schneider <[email protected]>
CommitDate: 2023-01-04 17:34:40 +0000

    Firefox opensearch autocomplete workarounds
---
 website/content/en/cgi/ports.cgi | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/website/content/en/cgi/ports.cgi b/website/content/en/cgi/ports.cgi
index e163f4a23f..0e6d425ee6 100755
--- a/website/content/en/cgi/ports.cgi
+++ b/website/content/en/cgi/ports.cgi
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -T
 #
-# Copyright (c) 1996-2022 Wolfram Schneider <[email protected]>
+# Copyright (c) 1996-2023 Wolfram Schneider <[email protected]>
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -496,7 +496,7 @@ sub footer {
 
     print qq{
 <img align="right" src="$hsty_base/gifs/powerlogo.gif" alt="Powered by FreeBSD" />
-&copy; 1996-2022 by Wolfram Schneider. All rights reserved.<br />
+&copy; 1996-2023 by Wolfram Schneider. All rights reserved.<br />
 };
 
 #print q{$FreeBSD$} . "<br />\n";
@@ -507,6 +507,24 @@ sub footer {
     print qq{<hr noshade="noshade" />\n<p />\n};
 }
 
+sub check_query {
+    my ($query, $sourceid) = @_;
+
+    $query =~ s/"/ /g;
+    $query =~ s/^\s+//;
+    $query =~ s/\s+$//;
+
+    # XXX: Firefox opensearch autocomplete workarounds
+    if ($sourceid eq 'opensearch') {
+	# remove space before a dot 
+	$query =~ s/ \././g;
+	# remove space between double colon
+	$query =~ s/: :/::/g;
+    }
+
+    return $query;
+}
+
 sub check_input {
     if ($query) {
         $stype = "all" if !$stype;
@@ -571,6 +589,7 @@ $section     = $form{'sektion'};
 $section     = 'all' if ( !$section );
 $query       = $form{'query'};
 $stype       = $form{'stype'};
+$sourceid    = $form{'sourceid'} // "";
 $script_name = &env('SCRIPT_NAME');
 
 if ( $path_info eq "/source" ) {
@@ -602,9 +621,7 @@ if ( !$query && $query_string =~ /^([^=&]+)$/ ) {
 # automatically read collections, need only 0.2 sec on a pentium
 @sec = &readcoll;
 
-$query =~ s/"/ /g;
-$query =~ s/^\s+//;
-$query =~ s/\s+$//;
+$query = &check_query($query, $sourceid);
 &forms;
 
 if ( $query_string eq "" || !$query ) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.