Skip to content

Commit

Permalink
Item13001: specify security setting for REST
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Aug 28, 2014
1 parent 2636b29 commit 543ce8b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
11 changes: 11 additions & 0 deletions .gitignore
@@ -0,0 +1,11 @@
*.gz
*.swp
pub/System/HarvestPlugin/harvest.css
pub/System/HarvestPlugin/harvest.js
HarvestPlugin.md5
HarvestPlugin.sha1
HarvestPlugin.tgz
HarvestPlugin.txt
HarvestPlugin.zip
HarvestPlugin_installer
HarvestPlugin_installer.pl
5 changes: 3 additions & 2 deletions data/System/HarvestPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="BaseUserMapping_999" comment="autosave" date="1356278772" format="1.1" version="3"}%
%META:TOPICINFO{author="ProjectContributor" comment="autosave" date="1356278772" format="1.1" version="3"}%

---+!! %TOPIC%

Expand Down Expand Up @@ -30,11 +30,12 @@ have to modify your local !PatternSkin to add this tool to your site.
-->

| Author(s): | Michael Daum|
| Copyright: | © 2012-2013 Michael Daum http://michaeldaumconsulting.com |
| Copyright: | © 2012-2014 Michael Daum http://michaeldaumconsulting.com |
| License: | [[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]] |
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 04 Apr 2014 | flag rest handlers that don't require authentication |
| 12 Dec 2013 | first dot.oh release |
| Dependencies: | %$DEPENDENCIES% |
| Home page: | Foswiki:Extensions/%TOPIC% |
Expand Down
14 changes: 9 additions & 5 deletions lib/Foswiki/Plugins/HarvestPlugin.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# HarvestPlugin is Copyright (C) 2011-2013 Michael Daum http://michaeldaumconsulting.com
# HarvestPlugin is Copyright (C) 2011-2014 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -27,8 +27,8 @@ use warnings;
use Foswiki::Func ();
use Foswiki::Contrib::JsonRpcContrib ();

our $VERSION = '1.00';
our $RELEASE = '1.00';
our $VERSION = '1.01';
our $RELEASE = '1.01';
our $SHORTDESCRIPTION = 'Download and archive resources from the web';
our $NO_PREFS_IN_TOPIC = 1;
our $baseWeb;
Expand All @@ -48,8 +48,12 @@ sub initPlugin {
Foswiki::Contrib::JsonRpcContrib::registerMethod('HarvestPlugin', 'attach', sub { return getCore()->jsonRpcAttach(@_); });

Foswiki::Func::registerRESTHandler('url2tml', sub {
return getCore()->restUrl2Tml(@_);
}, authenticate => 0); # TODO: convert to JsonRpcContrib
return getCore()->restUrl2Tml(@_);
},
authenticate => 0,
validate => 0,
http_allow => 'GET,POST',
); # TODO: convert to JsonRpcContrib

return 1;
}
Expand Down
12 changes: 7 additions & 5 deletions lib/Foswiki/Plugins/HarvestPlugin/Core.pm
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# HarvestPlugin is Copyright (C) 2011-2013 Michael Daum http://michaeldaumconsulting.com
# HarvestPlugin is Copyright (C) 2011-2014 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -26,7 +26,7 @@ use Error qw(:try);
use Encode ();
use URI ();

use constant DEBUG => 0; # toggle me
use constant TRACE => 0; # toggle me

# Error codes for json-rpc response
# 1000: no url
Expand All @@ -42,12 +42,12 @@ use constant DEBUG => 0; # toggle me
---++ writeDebug($message(
prints a debug message to STDERR when this module is in DEBUG mode
prints a debug message to STDERR when this module is in TRACE mode
=cut

sub writeDebug {
print STDERR "HarvestPlugin::Core - $_[0]\n" if DEBUG;
print STDERR "HarvestPlugin::Core - $_[0]\n" if TRACE;
}

=begin TML
Expand Down Expand Up @@ -165,7 +165,7 @@ sub restUrl2Tml {

# cleanup
$content =~ s/^.*<body.*?>(.*)<\/body>.*$/$1/s;
$content =~ s/<!-- .* -->//g;
$content =~ s/<!--.*-->//g;
$content =~ s/<!\[CDATA\[.*?\]\](>|&gt;)//gs; # remove junk
$content =~ s/<script.*?>.*?<\/script>//gs;
$content =~ s/<fb.*?>.*?<\/fb.*?>//gs;
Expand Down Expand Up @@ -558,6 +558,8 @@ sub getExternalResource {
#my $content = $res->content;
my $content = $res->decoded_content();

$content = Encode::encode($Foswiki::cfg{Site}{CharSet}, $content);

if ($cache) {
writeDebug("caching content for $url");
$cache->set(_cache_key($url), $content);
Expand Down
2 changes: 1 addition & 1 deletion pub/System/HarvestPlugin/harvest.uncompressed.css
Expand Up @@ -8,7 +8,7 @@
#downloadForm {
display:none;
}
.natRevision {
.foswikiRevision {
display:none;
}
.harvestResults {
Expand Down

0 comments on commit 543ce8b

Please sign in to comment.