pretty_proxy 4.0.5 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pretty_proxy.rb +18 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4be42b0d496b149d2697367b6357dc69704dabd
|
4
|
+
data.tar.gz: b822e0d942bf5feec3e8a82bbecf8735ba01e069
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b18c943cc12069dd3fed37aeaadaf0b3482bd9b876ad3e5e4e4f66fe28f7271408968b7e161804b9843cc13f37837ad2e5e62c0d702b29aa067587b7cf1de9f
|
7
|
+
data.tar.gz: de5a5dc56cf624c4be0a66d337f91546ebac270239ec1995364280abd6457b4a5b68f360ac34e2959523a54db9c5419285ad384aa4ce4c7e0639f88a4ab9aac7
|
data/lib/pretty_proxy.rb
CHANGED
@@ -86,6 +86,7 @@ class PrettyProxy < Rack::Proxy
|
|
86
86
|
@proxy_path = nil
|
87
87
|
@original_domain = nil
|
88
88
|
@original_paths = nil
|
89
|
+
attr_accessor :ignore_html_errors
|
89
90
|
|
90
91
|
# Create a new PrettyProxy instance or raise a ConfigError. Clone the arguments.
|
91
92
|
# @param proxy_path [String] Start and end with slashes, represent the
|
@@ -96,14 +97,19 @@ class PrettyProxy < Rack::Proxy
|
|
96
97
|
# to where the proxy map.
|
97
98
|
# @param original_paths [String, #each] The path (or the paths) to be mapped
|
98
99
|
# right inside the proxy_path (has to begin with slash).
|
100
|
+
# @param ignore_html_errors [TrueClass, FalseClass] If the argument of this
|
101
|
+
# parameter is true the #proxify_html try to ignore some exceptions that can
|
102
|
+
# be caused by an malformed (X)HTML and continue. Don't silence
|
103
|
+
# #{sugared_,}rewrite_response. Experimental.
|
99
104
|
# @note See the specs {file:../spec/pretty_proxy_spec.rb} for examples and
|
100
105
|
# complete definition of invalid args.
|
101
106
|
# @return [PrettyProxy] a new instance
|
102
107
|
# @raise PrettyProxy::ConfigError
|
103
|
-
def initialize(proxy_path, original_domain, original_paths)
|
108
|
+
def initialize(proxy_path, original_domain, original_paths, ignore_html_errors = false)
|
104
109
|
Utils.validate_proxy_path(proxy_path)
|
105
110
|
Utils.validate_original_domain_and_paths(original_domain, original_paths)
|
106
111
|
|
112
|
+
@ignore_html_errors = ignore_html_errors
|
107
113
|
@proxy_path = proxy_path.clone
|
108
114
|
@original_domain = Addressable::URI.parse(original_domain.clone)
|
109
115
|
@original_paths = Set.new
|
@@ -225,9 +231,17 @@ class PrettyProxy < Rack::Proxy
|
|
225
231
|
|
226
232
|
# the href isn't a obrigatory attribute of an anchor element
|
227
233
|
parsed_html.css('a[href]').each do | hyperlink |
|
228
|
-
|
229
|
-
|
230
|
-
|
234
|
+
begin
|
235
|
+
absolute_hyperlink = Addressable::URI.parse(base_url)
|
236
|
+
.join(hyperlink['href']).to_s
|
237
|
+
hyperlink['href'] = proxify_hyperlink(absolute_hyperlink, proxy_url)
|
238
|
+
rescue => e
|
239
|
+
# Here we catch any exception derived from StandardError and do nothing
|
240
|
+
# with it. This is a little risky, but the link in the href can be
|
241
|
+
# wrong in many ways and yet be accepted by nokogiri. So to not
|
242
|
+
# complexify the code we simply ignore when we can't proxify a link.
|
243
|
+
raise e unless @ignore_html_errors
|
244
|
+
end
|
231
245
|
end
|
232
246
|
|
233
247
|
unless base_tag
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pretty_proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrique Becker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|