Repository navigation
Require compile-time constants in JspBase.unsafe() - #1250
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
labkey-matthewb
approved these changes
Nov 20, 2026
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/platform
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/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 - 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 - `HtmlStringBuilder` appends another builder directly, without copying it into an intermediate `HtmlString` - Minor cleanups in `ReturnUrlForm` and the devtools module - The analytics tracking script is returned as trusted HTML from the service instead of being passed to `unsafe()` by each page template 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/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/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.
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 resultsReturnUrlFormand the devtools moduleVerified 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.