Skip to content

Commit

Permalink
Fix validation in custom headers (#93)
Browse files Browse the repository at this point in the history
* Fix validation in custom headers
  • Loading branch information
GrakovNe authored Dec 22, 2024
1 parent 99e37b9 commit 3e13818
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
applicationId = "org.grakovne.lissen"
minSdk = 28
targetSdk = 35
versionCode = 57
versionName = "1.1.26"
versionCode = 58
versionName = "1.1.27"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ data class ServerRequestHeader(
return this.copy(name = name, value = value)
}

private fun String.clean(): String = this.replace(Regex("[^a-zA-Z0-9-]"), "").trim()
/**
* Cleans this string to contain only valid tchar characters for HTTP header names as per RFC 7230.
*
* @return A string containing only allowed tchar characters.
*/
private fun String.clean(): String {
val invalidCharacters = Regex("[^!#\$%&'*+\\-.^_`|~0-9A-Za-z]")
return this.replace(invalidCharacters, "").trim()
}
}
}

0 comments on commit 3e13818

Please sign in to comment.