Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@W-8522881@ Invalidate input URL if it contains special characters #534

Merged
merged 8 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import com.twitter.chill.Base64.{InputStream => Base64InputStream}
import org.apache.commons.io.input.CharSequenceInputStream
import org.apache.commons.validator.routines.UrlValidator

import scala.util.Try

/**
* Text value representation
*
Expand Down Expand Up @@ -171,7 +173,7 @@ class URL(value: Option[String]) extends Text(value){
* RFC2396 (http://www.ietf.org/rfc/rfc2396.txt)
* Default valid protocols are: http, https, ftp.
*/
def isValid: Boolean = value.exists(UrlValidator.getInstance().isValid)
def isValid: Boolean = value.exists(v => UrlValidator.getInstance().isValid(v) && Try(new java.net.URL(v)).isSuccess)
/**
* Verifies if the url is of correct form of "Uniform Resource Identifiers (URI): Generic Syntax"
* RFC2396 (http://www.ietf.org/rfc/rfc2396.txt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class URLTest extends PropSpec with PropertyChecks with TestCommon {
Some("ftp://.codomain"),
Some("https://.codomain"),
Some("//domain.nambia"),
Some("http://\u00ff\u0080\u007f\u0000.com") // scalastyle:off
Some("http://\u00ff\u0080\u007f\u0000.com"), // scalastyle:off
Some("http://specialchars.@.com")
)

val goodOnes = Table("good ones",
Expand Down