Skip to content

[MINOR][UI] Encode query parameters when generating log page scripts#57165

Open
holdenk wants to merge 4 commits into
apache:masterfrom
holdenk:spark-log-viewer-minor-ui-improvement
Open

[MINOR][UI] Encode query parameters when generating log page scripts#57165
holdenk wants to merge 4 commits into
apache:masterfrom
holdenk:spark-log-viewer-minor-ui-improvement

Conversation

@holdenk

@holdenk holdenk commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

The log viewer pages assemble a query string from request parameters and embed it into an inline script literal. Encode that value for a JavaScript string context using the bundled commons-text StringEscapeUtils, matching the existing pattern in AllJobsPage, so the generated script stays well-formed regardless of the parameter contents.

Why are the changes needed?

Formatting can get funky with unescaped parameters.

Does this PR introduce any user-facing change?

No

How was this patch tested?

New test

Was this patch authored or co-authored using generative AI tooling?

Primarily Claude 4.8

Claude and others added 2 commits July 2, 2026 14:18
The log viewer pages assemble a query string from request parameters and
embed it into an inline script literal. Encode that value for a JavaScript
string context using the bundled commons-text StringEscapeUtils, matching
the existing pattern in AllJobsPage, so the generated script stays
well-formed regardless of the parameter contents. Also sanitize the
parameters on the client side in log-view.js, and add a regression test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Holden Karau <holden@pigscanfly.ca>
Co-Authored-By: Holden Karau <holden.karau@snowflake.com>
Encode individual query-parameter values on the server when building the
log page bootstrap script, so the resulting /log requests are unambiguous.
Extract the shared script-building helper into UIUtils to keep the log
pages consistent. The server now emits a fully-encoded query string, so
the client-side handling is reverted to a straight pass-through.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmZGbR3Y8L84RfcfqptgGW
@dongjoon-hyun

Copy link
Copy Markdown
Member

cc @huaxingao

@huaxingao huaxingao left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Pending CI

@dongjoon-hyun dongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the PR description, what does this mean? Apparently, this PR seems to have no change on log-view.js, @holdenk ?

Also sanitize the parameters on the client side in log-view.js

Comment thread core/src/main/scala/org/apache/spark/ui/UIUtils.scala Outdated
val worker = mock(classOf[Worker])
val tmpDir = new File(sys.props("java.io.tmpdir"))
val workDir = new File(tmpDir, "work-dir")
workDir.mkdir()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a new test case, shall we use withTempDir?

    withTempDir { workDir =>
      val webui = mock(classOf[WorkerWebUI])
      val worker = mock(classOf[Worker])
      when(webui.workDir).thenReturn(workDir)
       ...
    }

@dongjoon-hyun dongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@holdenk

holdenk commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@dongjoon-hyun thanks for the review, and good catch with the description, was left over from earlier version

holdenk and others added 2 commits July 9, 2026 22:19
Co-authored-by: Dongjoon Hyun <dongjoon@apache.org>

@dongjoon-hyun dongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for revision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants