govuk_content_models 31.3.0 → 31.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 958538091c31245d3c30d1007839a122b43e661b
4
- data.tar.gz: d80419824d3224945339326583163a70c018fe9b
3
+ metadata.gz: 40258d79cad346c7ad24fd75eab16db040358d7c
4
+ data.tar.gz: fbcb1c49048321f69113c637c9abdd16a00391f8
5
5
  SHA512:
6
- metadata.gz: ce9da9e40bc9b2fb21aaa114b1713e4c495b0ce74ed7d5370d5be96d91a0fd622fd77930078701913d7afdbbe77d3ec936fd6a858efe282bcaf1412e3afb5b44
7
- data.tar.gz: dd73d319e49c6c15db262f85f25e8d2eb6ebe9389a76dfc62ed5325592eeac4b95b30c00830dc9dfe1d5960109f4917acde09f3065878ea86cb3186645abea2d
6
+ metadata.gz: be04aedd7bb95a1523e44da86185e2004fd21b2dc5fc916e814ea9deee7c4d34e9b3137e7d7c19322e69b6b5f9a715c75b480839b879af8c7456be4289bce41b
7
+ data.tar.gz: 535ca3d75b80953e884fd95cdb8d21cd2b36150f01981b50da64111943288626c9415e82762e81e2c557b8d2409738664d24eee910280ed21fd23af84a0b26ee
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 31.4.0
4
+
5
+ - Allow URLs with fragments in Artefact#redirect_url
6
+
3
7
  ## 31.3.0
4
8
 
5
9
  - Include matching type-specific fields when converting editions
@@ -401,8 +401,15 @@ class Artefact
401
401
 
402
402
  def validate_redirect_url
403
403
  return unless self.redirect_url.present?
404
- unless valid_url_path?(self.redirect_url)
404
+ unless valid_redirect_url_path?(self.redirect_url)
405
405
  errors[:redirect_url] << "is not a valid redirect target"
406
406
  end
407
407
  end
408
+
409
+ def valid_redirect_url_path?(target)
410
+ URI.parse(target)
411
+ target.starts_with?("/") && target !~ %r{//} && target !~ %r{./\z}
412
+ rescue URI::InvalidURIError
413
+ false
414
+ end
408
415
  end
@@ -1,4 +1,4 @@
1
1
  module GovukContentModels
2
2
  # Changing this causes Jenkins to tag and release the gem into the wild
3
- VERSION = "31.3.0"
3
+ VERSION = "31.4.0"
4
4
  end
@@ -240,8 +240,24 @@ class ArtefactTest < ActiveSupport::TestCase
240
240
  artefact.redirect_url = "/foobar"
241
241
  assert artefact.valid?
242
242
 
243
+ artefact.redirect_url = "/foobar?an=argument"
244
+ assert artefact.valid?
245
+
246
+ artefact.redirect_url = "/foobar#chapter"
247
+ assert artefact.valid?
248
+
243
249
  artefact.redirect_url = "http://foo.bar/"
244
250
  refute artefact.valid?
251
+
252
+ [
253
+ "\jkhsdfgjkhdjskfgh//fdf#th",
254
+ "not a URL path",
255
+ "bar/baz",
256
+ "/foo//bar",
257
+ ].each do |invalid_path|
258
+ artefact.redirect_url = invalid_path
259
+ refute artefact.valid?
260
+ end
245
261
  end
246
262
 
247
263
  test "should translate kind into internally normalised form" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_content_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 31.3.0
4
+ version: 31.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Battley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-26 00:00:00.000000000 Z
11
+ date: 2015-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bson_ext