Repository navigation
Require compile-time constants in JspBase.unsafe() - #8370
Merged
Merged
Conversation
Annotate JspBase.unsafe() with @CompileTimeConstant and convert JSPs that passed it dynamic strings to HtmlString, h(), link builders, or JSON.
This was referenced Nov 19, 2026
The tracking script is trusted markup, so the service declares it once instead of each template passing it to unsafe().
labkey-matthewb
approved these changes
Nov 20, 2026
labkey-matthewb
left a comment
Contributor
There was a problem hiding this comment.
Only comment that might need action is search.jsp.
labkey-adam
added a commit
to LabKey/targetedms
that referenced
this pull request
Nov 21, 2026
## Rationale This PR makes `JspBase.unsafe()` accept only compile-time constants, so JSPs can no longer write dynamic strings to the page without encoding them. Error Prone enforces the new `@CompileTimeConstant` annotation, and this PR converts the callers that passed dynamic strings in the most common patterns. About 75 non-constant callers remain for follow-up work, nearly all in platform; they fail only in builds run with `-PerrorProne`. ## Related Pull Requests - LabKey/platform#8370 - LabKey/testAutomation#3314 - LabKey/commonAssays#1115 - LabKey/customModules#295 - LabKey/ehrModules#1250 - LabKey/premiumModules#877 - LabKey/LabDevKitModules#332 - LabKey/internalModules#177 - LabKey/clientModules#158 - LabKey/MacCossLabModules#695 - LabKey/wnprc-modules#1095 ## Changes - The download menu's tracking check works with the analytics tracking script now being returned as HTML - The figures of merit page and the spectrum viewer write their CV limit and chart selector as JavaScript values instead of passing strings to `unsafe()` Not compiled locally because this module isn't in my build; checked with IntelliJ inspections.
labkey-adam
added a commit
to LabKey/wnprc-modules
that referenced
this pull request
Nov 21, 2026
## Rationale This PR makes `JspBase.unsafe()` accept only compile-time constants, so JSPs can no longer write dynamic strings to the page without encoding them. Error Prone enforces the new `@CompileTimeConstant` annotation, and this PR converts the callers that passed dynamic strings in the most common patterns. About 75 non-constant callers remain for follow-up work, nearly all in platform; they fail only in builds run with `-PerrorProne`. ## Related Pull Requests - LabKey/platform#8370 - LabKey/testAutomation#3314 - LabKey/commonAssays#1115 - LabKey/customModules#295 - LabKey/ehrModules#1250 - LabKey/premiumModules#877 - LabKey/LabDevKitModules#332 - LabKey/internalModules#177 - LabKey/clientModules#158 - LabKey/MacCossLabModules#695 - LabKey/targetedms#1310 ## Changes - The necropsy report, necropsy collection list, and death notification encode database values, including multiline notes, instead of passing them to `unsafe()`, keeping their fixed "not specified" markup as trusted constants - The pathology case list and water calendar write their JSON data to the page as JSON values Not compiled locally because this module isn't in my build; checked with IntelliJ inspections.
labkey-adam
added a commit
to LabKey/customModules
that referenced
this pull request
Nov 21, 2026
## Rationale This PR makes `JspBase.unsafe()` accept only compile-time constants, so JSPs can no longer write dynamic strings to the page without encoding them. Error Prone enforces the new `@CompileTimeConstant` annotation, and this PR converts the callers that passed dynamic strings in the most common patterns. About 75 non-constant callers remain for follow-up work, nearly all in platform; they fail only in builds run with `-PerrorProne`. ## Related Pull Requests - LabKey/platform#8370 - LabKey/testAutomation#3314 - LabKey/commonAssays#1115 - LabKey/ehrModules#1250 - LabKey/premiumModules#877 - LabKey/LabDevKitModules#332 - LabKey/internalModules#177 - LabKey/clientModules#158 - LabKey/MacCossLabModules#695 - LabKey/targetedms#1310 - LabKey/wnprc-modules#1095 ## Changes - `JspBase.unsafe()` requires a compile-time constant, and its `CharSequence` overload is removed - JSPs that built markup from strings now use `HtmlString`, `h()`, link and button builders, or JavaScript-safe encoding (`q()`, JSON) inside script blocks - The export-script view writes plain text directly instead of going through a JSP - `PageConfig.makeId()` rejects invalid prefixes - `LabKeyCollectors.joining()` keeps delimiters next to empty elements and when combining parallel results - Minor cleanups in `ReturnUrlForm` and the devtools module - Specimen visit report cells are built as `HtmlString`, with links built from `ActionURL` and `LinkBuilder` instead of query strings and hand-coded tags - The specimen display-settings enum renders itself directly, and the remaining specimen pages encode plain-text values with `h()` Verified with `-PerrorProne` compiles of the api, core, and search modules, the `PageConfig` and `LabKeyCollectors` unit tests on a local server, `AbstractExportTest`, and manual checks of the folder type, search, and export script pages.
labkey-adam
added a commit
to LabKey/commonAssays
that referenced
this pull request
Nov 21, 2026
## Rationale This PR makes `JspBase.unsafe()` accept only compile-time constants, so JSPs can no longer write dynamic strings to the page without encoding them. Error Prone enforces the new `@CompileTimeConstant` annotation, and this PR converts the callers that passed dynamic strings in the most common patterns. About 75 non-constant callers remain for follow-up work, nearly all in platform; they fail only in builds run with `-PerrorProne`. ## Related Pull Requests - LabKey/platform#8370 - LabKey/testAutomation#3314 - LabKey/customModules#295 - LabKey/ehrModules#1250 - LabKey/premiumModules#877 - LabKey/LabDevKitModules#332 - LabKey/internalModules#177 - LabKey/clientModules#158 - LabKey/MacCossLabModules#695 - LabKey/targetedms#1310 - LabKey/wnprc-modules#1095 ## Changes - `JspBase.unsafe()` requires a compile-time constant, and its `CharSequence` overload is removed - JSPs that built markup from strings now use `HtmlString`, `h()`, link and button builders, or JavaScript-safe encoding (`q()`, JSON) inside script blocks - The export-script view writes plain text directly instead of going through a JSP - `PageConfig.makeId()` rejects invalid prefixes - `LabKeyCollectors.joining()` keeps delimiters next to empty elements and when combining parallel results - Minor cleanups in `ReturnUrlForm` and the devtools module - Flow compensation, analysis-import, and run-import pages encode workspace subset names and the graph-size preference, and build their selects and image markup with builders instead of passing strings to `unsafe()` or hand-written tags - The ms2 search-defaults editors encode their configuration XML, and the remaining flow, luminex, and ms2 pages encode plain-text values Verified with `-PerrorProne` compiles of the api, core, and search modules, the `PageConfig` and `LabKeyCollectors` unit tests on a local server, `AbstractExportTest`, and manual checks of the folder type, search, and export script pages.
labkey-adam
added a commit
to LabKey/ehrModules
that referenced
this pull request
Nov 21, 2026
## Rationale This PR makes `JspBase.unsafe()` accept only compile-time constants, so JSPs can no longer write dynamic strings to the page without encoding them. Error Prone enforces the new `@CompileTimeConstant` annotation, and this PR converts the callers that passed dynamic strings in the most common patterns. About 75 non-constant callers remain for follow-up work, nearly all in platform; they fail only in builds run with `-PerrorProne`. ## Related Pull Requests - LabKey/platform#8370 - LabKey/testAutomation#3314 - LabKey/commonAssays#1115 - LabKey/customModules#295 - LabKey/premiumModules#877 - LabKey/LabDevKitModules#332 - LabKey/internalModules#177 - LabKey/clientModules#158 - LabKey/MacCossLabModules#695 - LabKey/targetedms#1310 - LabKey/wnprc-modules#1095 ## Changes - `JspBase.unsafe()` requires a compile-time constant, and its `CharSequence` overload is removed - JSPs that built markup from strings now use `HtmlString`, `h()`, link and button builders, or JavaScript-safe encoding (`q()`, JSON) inside script blocks - The export-script view writes plain text directly instead of going through a JSP - `PageConfig.makeId()` rejects invalid prefixes - `LabKeyCollectors.joining()` keeps delimiters next to empty elements and when combining parallel results - Minor cleanups in `ReturnUrlForm` and the devtools module Verified with `-PerrorProne` compiles of the api, core, and search modules, the `PageConfig` and `LabKeyCollectors` unit tests on a local server, `AbstractExportTest`, and manual checks of the folder type, search, and export script pages.
labkey-adam
added a commit
to LabKey/MacCossLabModules
that referenced
this pull request
Nov 21, 2026
## Rationale This PR makes `JspBase.unsafe()` accept only compile-time constants, so JSPs can no longer write dynamic strings to the page without encoding them. Error Prone enforces the new `@CompileTimeConstant` annotation, and this PR converts the callers that passed dynamic strings in the most common patterns. About 75 non-constant callers remain for follow-up work, nearly all in platform; they fail only in builds run with `-PerrorProne`. ## Related Pull Requests - LabKey/platform#8370 - LabKey/testAutomation#3314 - LabKey/commonAssays#1115 - LabKey/customModules#295 - LabKey/ehrModules#1250 - LabKey/premiumModules#877 - LabKey/LabDevKitModules#332 - LabKey/internalModules#177 - LabKey/clientModules#158 - LabKey/targetedms#1310 - LabKey/wnprc-modules#1095 ## Changes - The LINCS download tracking check works with the analytics tracking script now being returned as HTML - The Skyline tool store builds its Download and Documentation button labels with `HtmlStringBuilder` instead of passing concatenated markup to `unsafe()` Not compiled locally because this module isn't in my build; checked with IntelliJ inspections.
labkey-adam
added a commit
to LabKey/LabDevKitModules
that referenced
this pull request
Nov 21, 2026
## Rationale This PR makes `JspBase.unsafe()` accept only compile-time constants, so JSPs can no longer write dynamic strings to the page without encoding them. Error Prone enforces the new `@CompileTimeConstant` annotation, and this PR converts the callers that passed dynamic strings in the most common patterns. About 75 non-constant callers remain for follow-up work, nearly all in platform; they fail only in builds run with `-PerrorProne`. ## Related Pull Requests - LabKey/platform#8370 - LabKey/testAutomation#3314 - LabKey/commonAssays#1115 - LabKey/customModules#295 - LabKey/ehrModules#1250 - LabKey/premiumModules#877 - LabKey/internalModules#177 - LabKey/clientModules#158 - LabKey/MacCossLabModules#695 - LabKey/targetedms#1310 - LabKey/wnprc-modules#1095 ## Changes - The laboratory data browser passes its filter types to the page as JSON instead of hand-built, HTML-encoded script text Not compiled or tested locally because the laboratory module isn't in my build.
labkey-adam
added a commit
to LabKey/testAutomation
that referenced
this pull request
Nov 21, 2026
## Rationale This PR makes `JspBase.unsafe()` accept only compile-time constants, so JSPs can no longer write dynamic strings to the page without encoding them. Error Prone enforces the new `@CompileTimeConstant` annotation, and this PR converts the callers that passed dynamic strings in the most common patterns. About 75 non-constant callers remain for follow-up work, nearly all in platform; they fail only in builds run with `-PerrorProne`. ## Related Pull Requests - LabKey/platform#8370 - LabKey/commonAssays#1115 - LabKey/customModules#295 - LabKey/ehrModules#1250 - LabKey/premiumModules#877 - LabKey/LabDevKitModules#332 - LabKey/internalModules#177 - LabKey/clientModules#158 - LabKey/MacCossLabModules#695 - LabKey/targetedms#1310 - LabKey/wnprc-modules#1095 ## Changes - `JspBase.unsafe()` requires a compile-time constant, and its `CharSequence` overload is removed - JSPs that built markup from strings now use `HtmlString`, `h()`, link and button builders, or JavaScript-safe encoding (`q()`, JSON) inside script blocks - The export-script view writes plain text directly instead of going through a JSP - `PageConfig.makeId()` rejects invalid prefixes - `LabKeyCollectors.joining()` keeps delimiters next to empty elements and when combining parallel results - Minor cleanups in `ReturnUrlForm` and the devtools module - The dumbster mail page builds its header list with `HtmlStringBuilder`, and it and the crawler injection page mark their deliberately raw HTML with an explicit `HtmlString.unsafe()` Verified with `-PerrorProne` compiles of the api, core, and search modules, the `PageConfig` and `LabKeyCollectors` unit tests on a local server, `AbstractExportTest`, and manual checks of the folder type, search, and export script pages.
labkey-adam
added a commit
that referenced
this pull request
Nov 28, 2026
## Rationale This PR removes the remaining non-constant `JspBase.unsafe()` calls in platform, the follow-up to #8370, so builds with `-PerrorProne` report no `CompileTimeConstant` warnings from JSPs. Along the way it fixes several places where unencoded values reached the page, including group names rendered as HTML in membership tooltips and a request-supplied participant view script. ## Related Pull Requests - LabKey/limsModules#2641 ## Changes - JSPs encode dynamic values with `h()`, write static markup directly, or use `q()` in script blocks instead of passing built strings to `unsafe()` - Renderers that built HTML strings (custom properties, issue detail info, pipeline delete confirmation, search indexer stats) now return `HtmlString` - `Visit.SequenceHandling` is safe to render directly - The plain-text file digest email is built in Java instead of a JSP - Membership tooltips encode their HTML for the attribute, and the participant view preview uses only the saved script - Fixed double-encoded labels on the dataset display order page and a malformed row tag in issue details Verified with a `-PerrorProne` compile of all platform modules and JSPs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale
This PR makes
JspBase.unsafe()accept only compile-time constants, so JSPs can no longer write dynamic strings to the page without encoding them. Error Prone enforces the new@CompileTimeConstantannotation, and this PR converts the callers that passed dynamic strings in the most common patterns. About 75 non-constant callers remain for follow-up work, nearly all in platform; they fail only in builds run with-PerrorProne.Related Pull Requests
Changes
JspBase.unsafe()requires a compile-time constant, and itsCharSequenceoverload is removedHtmlString,h(), link and button builders, or JavaScript-safe encoding (q(), JSON) inside script blocksPageConfig.makeId()rejects invalid prefixesLabKeyCollectors.joining()keeps delimiters next to empty elements and when combining parallel resultsHtmlStringBuilderappends another builder directly, without copying it into an intermediateHtmlStringReturnUrlFormand the devtools moduleunsafe()by each page templateVerified with
-PerrorPronecompiles of the api, core, and search modules, thePageConfigandLabKeyCollectorsunit tests on a local server,AbstractExportTest, and manual checks of the folder type, search, and export script pages.