rspec/rules/S3995/rule.adoc

43 lines
775 B
Plaintext
Raw Normal View History

2020-12-23 14:59:06 +01:00
String representations of URIs or URLs are prone to parsing and encoding errors which can lead to vulnerabilities. The ``System.Uri`` class is a safe alternative and should be preferred.
2020-06-30 12:48:39 +02:00
2020-12-23 14:59:06 +01:00
This rule raises an issue when a method has a ``string`` return type and its name contains "Uri", "Urn", or "Url" or begins with "uri", "urn", or "url".
2020-06-30 12:48:39 +02:00
== Noncompliant Code Example
----
using System;
namespace MyLibrary
{
public class MyClass
{
public string GetParentUri() // Noncompliant
{
return "http://www.mysite.com";
}
}
}
----
== Compliant Solution
----
using System;
namespace MyLibrary
{
public class MyClass
{
public Uri GetParentUri()
{
return new URI("http://www.mysite.com");
}
}
}
----