Skip to content

Commit

Permalink
[Student][Teacher][MBL-14758] Sanitize author name in discussion HTML…
Browse files Browse the repository at this point in the history
…, bump version codes (#1011)
  • Loading branch information
JordanMarshall authored Sep 22, 2020
1 parent a3b766f commit 5fbeb36
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/student/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ android {
applicationId "com.instructure.candroid"
minSdkVersion Versions.MIN_SDK
targetSdkVersion Versions.TARGET_SDK
versionCode = 219
versionCode = 220
versionName = '6.9.1'

vectorDrawables.useSupportLibrary = true
Expand Down
2 changes: 1 addition & 1 deletion apps/teacher/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ android {
defaultConfig {
minSdkVersion Versions.MIN_SDK
targetSdkVersion Versions.TARGET_SDK
versionCode = 32
versionCode = 33
versionName = '1.11.2'
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
Expand Down
1 change: 1 addition & 0 deletions libs/pandautils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ dependencies {
api ('com.davemorrissey.labs:subsampling-scale-image-view:3.9.0') {
exclude group: "androidx.exifinterface"
}
implementation 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20200713.1'

/* Crashlytics */
implementation(Libs.CRASHLYTICS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.instructure.canvasapi2.utils.localized
import com.instructure.canvasapi2.utils.toDate
import com.instructure.pandautils.BuildConfig
import com.instructure.pandautils.R
import org.owasp.html.HtmlPolicyBuilder

/**
* Used to convert DiscussionEntries into HTML. Typically this class only takes data and does little calculation.
Expand Down Expand Up @@ -213,7 +214,7 @@ class DiscussionEntryHtmlConverter {

.replace("__AVATAR_URL__", avatarImage)
.replace("__AVATAR_ALT__", context.getString(R.string.userAvatar))
.replace("__TITLE__", authorName)
.replace("__TITLE__", sanitizePolicy.sanitize(authorName))
.replace("__DATE__", date)
.replace("__CONTENT_HTML__", content)
.replace("__HEADER_ID__", discussionEntry.id.toString())
Expand Down Expand Up @@ -295,5 +296,8 @@ class DiscussionEntryHtmlConverter {
discussionEntry.ratingSum.localized
)
}

// Use a default policy which should disallow all tags, attributes, etc.
private val sanitizePolicy = HtmlPolicyBuilder().toFactory()
}
}

0 comments on commit 5fbeb36

Please sign in to comment.