DOS attacks? This (looks like it) is a straight text substitution. I provide a list of however many linker types I want with a parameter for the stuff between linker:// and |. When I use foo://, you look up foo:// in my list and substitute, as appropriate. If foo:// doesn't exist, it's handled as it would be default.
Maybe I'm missing something, but that shouldn't open you up to a DOS ...
- In general, if you think something isn't in Perl, try it out, because it usually is. :-)
- "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"
| [reply] |
Here are the current link-handling settings:
| Setting | Value |
| cpan |
my $escapedname=$query->escape($nodeloc); my $cpantitle= $title || $nodeloc; return qq[<a href="http://search.cpan.org/search?mode=module&query=$escapedname">$cpantitle</a>]; |
| dict |
my $escapedname = $query->escape($nodeloc); my $x = $title || $nodeloc; return qq[<a href="http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=$escapedname">$x</a>]; |
| doc |
if ($escapedname =~ /^perl/) {qq[<a href="http://perldoc.perl.org/$escapedname.html">$cpantitle</a>];} else {qq[<a href="http://perldoc.perl.org/functions/$escapedname.html">$cpantitle</a>];} |
| ftp |
return $title ? qq[<a href="ftp://$nodeloc">$title</a>] : qq[<a href="ftp://$nodeloc">$nodeloc</a>]; |
| google |
my $escapedname=$query->escape($nodeloc); my $cpantitle= $title || $nodeloc; return qq[<a href="http://www.google.com/search?q=$escapedname">$cpantitle</a>]; |
| href |
return qq[<a href="$nodeloc">$cpantitle</a>] |
| http |
return $title ? qq[<a href="http://$nodeloc">$title</a>] : qq[<a href="http://$nodeloc">http://$nodeloc</a>]; |
| https |
return $title ? qq[<a href="https://$nodeloc">$title</a>] : qq[<a href="https://$nodeloc">https://$nodeloc</a>]; |
| id |
if($nodeloc=~/\D/) {return "[$inner]"} else {return $title ? linkNode($nodeloc, $title) : linkNode($nodeloc)}; |
| isbn |
$nodeloc =~ tr/0-9Xx//cd; my $cpantitle = $title || "ISBN $nodeloc"; "<a href='http://isbn.nu/$nodeloc'>$cpantitle</a>"; |
| jargon |
return qq[<a href="http://www.science.uva.nl/cng/search/htsearch.CGI?words=$escapedname&restrict=%2F%7Emes%2Fjargon%2F">$cpantitle</a>]; |
| kobe |
return qq[<a href="http://cpan.uwinnipeg.ca/search?query=$escapedname&mode=module">$cpantitle</a>]; |
| kobes |
return qq[<a href="http://cpan.uwinnipeg.ca/search?query=$escapedname&mode=module">$cpantitle</a>]; |
| link |
return qq[<a href="$nodeloc">$cpantitle</a>] |
| lj |
return qq[<a href="http://livejournal.com/users/$nodeloc">$cpantitle</a>]; |
| localtime |
$nodeloc="" if $nodeloc=~/now/i; return htmlcode('parseTimeInString', '', $nodeloc); |
| lucky |
my $escapedname = $query->escape($nodeloc); my $cpantitle= $title || $nodeloc; return qq[<a href="http://www.google.com/search?q=$escapedname&btnI=I">$cpantitle</a>]; |
| node |
return htmlcode('node_link', '', $inner, $nodeloc, $title, $cpantitle); |
| pad |
return htmlcode('scratchpad_link', '', $nodeloc||$AUTHOR->{title}, $title, {}); |
| perldoc |
return qq[<a href="http://www.perldoc.com/cgi-bin/htsearch?&words=$escapedname">$cpantitle</a>]; |
| pmdev |
return htmlcode('pmdev_link', '', $inner); |
Much of the complexity has been factored out already but there are still a lot of improvements for the infrastructure of link handling that are desired and partially implemented. But even what we have now isn't a simple text substitution. Provide the start of an enhancement to get your customization and it might get into the queue with the other enhancements that have yet to be deployed. Sometimes such a kick-start is exactly what is needed.
If you are missing something, then implementing it will probably rectify that situation. I don't see the obvious right way to do something like what you have asked for that I'd consider flexible to the point of being worth implementing, but I haven't sat down and tried to design it (but it appears you haven't sat down and tried to design it in any detail either so I don't feel particularly lazy in comparison).
| [reply] |
my $escapedname=$query->escape($nodeloc); my $cpantitle= $title || $no
+deloc; my $mode=$VARS->{cpan_link_opts} || 'mode=module'; return qq[<
+a href="http://search.cpan.org/search?$mode&query=$escapedname">$cpan
+title</a>];
IMO there isnt so much need for a general solution, I dont think that many of the link types can really benefit from such tricks.
---
$world=~s/war/peace/g
| [reply] [d/l] |
There seem to be two main types of links, with a few oddballs.
- Internal links, which are id, localtime, node, pad, and pmdev. These are the guys calling htmlcode(). I don't think v0.1 allows the ability to customize to a link using this.
- External HTML links, listed below*. These are the ones I think are excellent candidates for customizing. There seem to be 3 variables total that are used:
- %L - location
- %T - title (if given - defaults to %L)
- %E - $query->escape(%L);
- The oddballs. From your list, the only one is isbn, which has the tr/// and default to a different title in it. I think we can leave customizing that would allow for this one out of v0.1 and add it later.
So, if I read everything right, the linking methods would look something like:
- cpan: <a href="http://search.cpan.org/search?mode=module&query=%E">%T</a>
- link: <a href="%L">%T</a>
- google: <a href="http://www.google.com/search?q=%E">%T</a>
You get the point. Even if you don't expose this, I think it would make the internal code a lot easier to manage.
*External linking methods:
- cpan
- dict
- doc
- ftp
- google
- href
- http
- https
- jargon
- kobe
- kobes
- link
- lj
- lucky
- perldoc
- In general, if you think something isn't in Perl, try it out, because it usually is. :-)
- "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"
| [reply] [d/l] [select] |