Skip to content

Commit

Permalink
fix gocritic issue for internal sanitize (open-telemetry#11156)
Browse files Browse the repository at this point in the history
Signed-off-by: Ziqi Zhao <[email protected]>
  • Loading branch information
fatsheep9146 committed Jun 22, 2022
1 parent cf2df87 commit f76da84
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions internal/common/sanitize/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// nolint:gocritic
package sanitize // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/sanitize"

import (
Expand All @@ -23,13 +22,13 @@ import (
// URL removes control characters from the URL parameter. This addresses CWE-117:
// https://cwe.mitre.org/data/definitions/117.html
func URL(unsanitized *url.URL) string {
escaped := strings.Replace(unsanitized.String(), "\n", "", -1)
return strings.Replace(escaped, "\r", "", -1)
escaped := strings.ReplaceAll(unsanitized.String(), "\n", "")
return strings.ReplaceAll(escaped, "\r", "")
}

// String removes control characters from String parameter. This addresses CWE-117:
// https://cwe.mitre.org/data/definitions/117.html
func String(unsanitized string) string {
escaped := strings.Replace(unsanitized, "\n", "", -1)
return strings.Replace(escaped, "\r", "", -1)
escaped := strings.ReplaceAll(unsanitized, "\n", "")
return strings.ReplaceAll(escaped, "\r", "")
}

0 comments on commit f76da84

Please sign in to comment.