Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit37df638

Browse files
authored
@W-8522881@ Invalidate input URL if it contains special characters (#534)
* encoding url with uri in text* fixing test* address review feedback* fix indent and compile error* Change strategy to returning None if special chars in url domain* cleanup
1 parent91724f1 commit37df638

File tree

2 files changed

+5
-2
lines changed
  • features/src

2 files changed

+5
-2
lines changed

‎features/src/main/scala/com/salesforce/op/features/types/Text.scala‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import com.twitter.chill.Base64.{InputStream => Base64InputStream}
3838
importorg.apache.commons.io.input.CharSequenceInputStream
3939
importorg.apache.commons.validator.routines.UrlValidator
4040

41+
importscala.util.Try
42+
4143
/**
4244
* Text value representation
4345
*
@@ -171,7 +173,7 @@ class URL(value: Option[String]) extends Text(value){
171173
* RFC2396 (http://www.ietf.org/rfc/rfc2396.txt)
172174
* Default valid protocols are: http, https, ftp.
173175
*/
174-
defisValid:Boolean= value.exists(UrlValidator.getInstance().isValid)
176+
defisValid:Boolean= value.exists(v=>UrlValidator.getInstance().isValid(v)&&Try(new java.net.URL(v)).isSuccess)
175177
/**
176178
* Verifies if the url is of correct form of "Uniform Resource Identifiers (URI): Generic Syntax"
177179
* RFC2396 (http://www.ietf.org/rfc/rfc2396.txt)

‎features/src/test/scala/com/salesforce/op/features/types/URLTest.scala‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class URLTest extends PropSpec with PropertyChecks with TestCommon {
4848
Some("ftp://.codomain"),
4949
Some("https://.codomain"),
5050
Some("//domain.nambia"),
51-
Some("http://\u00ff\u0080\u007f\u0000.com")// scalastyle:off
51+
Some("http://\u00ff\u0080\u007f\u0000.com"),// scalastyle:off
52+
Some("http://specialchars.@.com")
5253
)
5354

5455
valgoodOnes=Table("good ones",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp