]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 108987 - Linkify script to use quoteUrls on texts provided by user. Patch by...
authorgerv%gerv.net <>
Sat, 21 Sep 2002 22:17:03 +0000 (22:17 +0000)
committergerv%gerv.net <>
Sat, 21 Sep 2002 22:17:03 +0000 (22:17 +0000)
bug_form.pl
globals.pl
long_list.cgi
page.cgi
process_bug.cgi
template/en/default/pages/linked.html.tmpl [new file with mode: 0644]
template/en/default/pages/linkify.html.tmpl [new file with mode: 0644]

index e6b59e051055eca67db741da7aec5bf1c7a7a19f..8d7a2b02ef58489c1081e4449344859cca513ab2 100644 (file)
@@ -58,7 +58,6 @@ sub show_bug {
     my $vars = $::vars;
     
     $vars->{'GetBugLink'} = \&GetBugLink;
-    $vars->{'quoteUrls'} = \&quoteUrls,
     $vars->{'lsearch'} = \&lsearch,
     $vars->{'header_done'} = (@_),
 
index 3edcab46040e5eeb90a11dab049ca8958d99e251..4570a5658082fcfdd0ca22233b25fe242e96c558 100644 (file)
@@ -1545,6 +1545,9 @@ $::vars =
     # Generic linear search function
     'lsearch' => \&Bugzilla::Util::lsearch ,
 
+    # quoteUrls - autolinkifies text
+    'quoteUrls' => \&quoteUrls ,
+    
     # UserInGroup - you probably want to cache this
     'UserInGroup' => \&UserInGroup ,
 
index eba094699758d7993b043355f430450f97e426d4..6acee0332aae7cb07ca4530a765765fcdc3c77bd 100755 (executable)
@@ -98,7 +98,6 @@ $vars->{'bugs'} = \@bugs;
 
 $vars->{'use_keywords'} = 1 if (@::legal_keywords);
 
-$vars->{'quoteUrls'} = \&quoteUrls;
 $vars->{'str2time'} = \&str2time;
 
 # Work out a sensible filename for Content-Disposition.
index af0903c3005764f560bed669dac7bac7cbe645f7..960774cc4b8106560dc97923855c0b9a8792f341 100755 (executable)
--- a/page.cgi
+++ b/page.cgi
@@ -39,11 +39,14 @@ ConnectToDatabase();
 
 quietly_check_login();
 
-if (defined $::FORM{'id'}) {
+if ($::FORM{'id'}) {
+    # Remove all dodgy chars, and split into name and ctype.
     $::FORM{'id'} =~ s/[^\w\-\.]//g;
-    $::FORM{'id'} =~ /(.*)(\.(.*))?/;
+    $::FORM{'id'} =~ /(.*)\.(.*)/;
 
-    my $format = GetFormat($1, undef, $3);
+    my $format = GetFormat($1, undef, $2);
+    
+    $vars->{'form'} = \%::FORM; 
     
     print "Content-Type: $format->{'ctype'}\n\n";
 
index be661c629b95f8542980ddd44c46cf4b27cf9305..f62285ffbb210654b64a5097c5758375a00bc7d3 100755 (executable)
@@ -1089,7 +1089,6 @@ foreach my $id (@idlist) {
         $vars->{'mform'} = \%::MFORM;
         
         $vars->{'bug_id'} = $id;
-        $vars->{'quoteUrls'} = \&quoteUrls;
         
         SendSQL("UNLOCK TABLES");
         
diff --git a/template/en/default/pages/linked.html.tmpl b/template/en/default/pages/linked.html.tmpl
new file mode 100644 (file)
index 0000000..8c854e2
--- /dev/null
@@ -0,0 +1,43 @@
+<!-- 1.0@bugzilla.org -->
+[%# The contents of this file are subject to the Mozilla Public
+  # License Version 1.1 (the "License"); you may not use this file
+  # except in compliance with the License. You may obtain a copy of
+  # the License at http://www.mozilla.org/MPL/
+  #
+  # Software distributed under the License is distributed on an "AS
+  # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+  # implied. See the License for the specific language governing
+  # rights and limitations under the License.
+  #
+  # The Original Code is the Bugzilla Bug Tracking System.
+  #
+  # The Initial Developer of the Original Code is Netscape Communications
+  # Corporation. Portions created by Netscape are
+  # Copyright (C) 1998 Netscape Communications Corporation. All
+  # Rights Reserved.
+  #
+  # Contributor(s): Stefan Seifert <nine@detonation.org>
+  #                 Gervase Markham <gerv@gerv.net>
+  #%]
+
+[% INCLUDE global/header.html.tmpl title = "Your Linkified Text" %]
+
+<p>
+  Copy and paste the text below:
+</p>
+
+<p>
+  <tt>
+    [% quoteUrls(form.text) FILTER html %]
+  </tt>
+</p>
+
+<p>
+  It will end up looking like this:
+</p>
+
+<p>
+  [% quoteUrls(form.text) %]
+</p>
+
+[% INCLUDE global/footer.html.tmpl %]
diff --git a/template/en/default/pages/linkify.html.tmpl b/template/en/default/pages/linkify.html.tmpl
new file mode 100644 (file)
index 0000000..57f455d
--- /dev/null
@@ -0,0 +1,38 @@
+<!-- 1.0@bugzilla.org -->
+[%# The contents of this file are subject to the Mozilla Public
+  # License Version 1.1 (the "License"); you may not use this file
+  # except in compliance with the License. You may obtain a copy of
+  # the License at http://www.mozilla.org/MPL/
+  #
+  # Software distributed under the License is distributed on an "AS
+  # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+  # implied. See the License for the specific language governing
+  # rights and limitations under the License.
+  #
+  # The Original Code is the Bugzilla Bug Tracking System.
+  #
+  # The Initial Developer of the Original Code is Netscape Communications
+  # Corporation. Portions created by Netscape are
+  # Copyright (C) 1998 Netscape Communications Corporation. All
+  # Rights Reserved.
+  #
+  # Contributor(s): Stefan Seifert <nine@detonation.org>
+  #                 Gervase Markham <gerv@gerv.net>
+  #%]
+
+[% INCLUDE global/header.html.tmpl title = "Linkify Text" %]
+
+<p>
+  If you enter some text, this form will return it marked up like a 
+  standard Bugzilla comment. That is, valid bug numbers, URLs, email addresses
+  and so on will be replaced with appropriate HTML links.
+</p>
+
+<form action="page.cgi" method="post">
+  <textarea cols="80" rows="20" name="text"></textarea>
+  <br>    
+  <input type="hidden" name="id" value="linked.html">
+  <input value="Linkify" type="submit">
+</form>
+
+[% INCLUDE global/footer.html.tmpl %]