Skip to content

fix escaping in iframes #1237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -314,29 +314,29 @@ private fun convertToDescription(dataframeLike: Any): String =
else -> throw IllegalArgumentException("Unsupported type: ${dataframeLike::class}")
}.escapeHtmlForIFrame()

internal fun String.escapeHtmlForIFrame(): String {
val str = this
return buildString {
for (c in str) {
when {
c.code > 127 || c == '\'' || c == '\\' -> {
append("&#")
append(c.code)
append(';')
}
internal fun String.escapeHtmlForIFrame(): String =
buildString {
for (c in this@escapeHtmlForIFrame) {
when (c) {
'<' -> append("&lt;")

'>' -> append("&gt;")

c == '"' -> append("&quot;")
'&' -> append("&amp;")

c == '<' -> append("&amp;lt;")
'"' -> append("&quot;")

c == '>' -> append("&amp;gt;")
'\'' -> append("&#39;")

c == '&' -> append("&amp;")
'\\' -> append("&#92;")

else -> {
append(c)
if (c.code > 127) {
append("&#${c.code};")
} else {
append(c)
}
}
}
}
}
}
2 changes: 0 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,3 @@ Code samples for the documentation website reside in [core/.../test/.../samples/
and [tests/.../samples/api](../tests/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api) (for samples can depend on other I/O modules)
and they are copied over to Markdown files in [docs/StardustDocs/topics](./StardustDocs/topics)
by [Korro](https://github.com/devcrocod/korro).


Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
</details>
<br>
<details>
<summary>df.select { colsOf&amp;lt;String&amp;gt;() }</summary>
<summary>df.select { colsOf&lt;String&gt;() }</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 6</summary>
<table class="dataframe" id="df_6"></table>
Expand All @@ -242,7 +242,7 @@
</details>
<br>
<details>
<summary>df.select { colsOf&amp;lt;String?&amp;gt; { it.countDistinct() &amp;gt; 5 } }</summary>
<summary>df.select { colsOf&lt;String?&gt; { it.countDistinct() &gt; 5 } }</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 6</summary>
<table class="dataframe" id="df_8"></table>
Expand Down Expand Up @@ -438,7 +438,7 @@
</details>
<br>
<details>
<summary>df.select { colsAtAnyDepth().colsOf&amp;lt;String&amp;gt;() }</summary>
<summary>df.select { colsAtAnyDepth().colsOf&lt;String&gt;() }</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 6</summary>
<table class="dataframe" id="df_32"></table>
Expand All @@ -454,7 +454,7 @@
</details>
<br>
<details>
<summary>df.select { allExcept { colsOf&amp;lt;String&amp;gt;() } }</summary>
<summary>df.select { allExcept { colsOf&lt;String&gt;() } }</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 6</summary>
<table class="dataframe" id="df_34"></table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
</details>
<br>
<details>
<summary>df.select { (colsOf&amp;lt;Int&amp;gt;() and age).distinct() }</summary>
<summary>df.select { (colsOf&lt;Int&gt;() and age).distinct() }</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
<table class="dataframe" id="df_12"></table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
</details>
<br>
<details>
<summary>df.fillNaNs { colsAtAnyDepth().colsOf&amp;lt;Double&amp;gt;() }.withZero()</summary>
<summary>df.fillNaNs { colsAtAnyDepth().colsOf&lt;Double&gt;() }.withZero()</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
<table class="dataframe" id="df_2"></table>
Expand Down Expand Up @@ -270,7 +270,7 @@
</details>
<br>
<details>
<summary>df.gather { colsOf&amp;lt;Number&amp;gt;() }.into(&quot;key&quot;, &quot;value&quot;)</summary>
<summary>df.gather { colsOf&lt;Number&gt;() }.into(&quot;key&quot;, &quot;value&quot;)</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
<table class="dataframe" id="df_12"></table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
</head>
<body>
<details>
<summary>df.minFor { colsOf&amp;lt;Int&amp;gt;() }</summary>
<summary>df.minFor { colsOf&lt;Int&gt;() }</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
<table class="dataframe" id="df_0"></table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
</details>
<br>
<details>
<summary>df.pivot { city }.count { age &amp;gt; 18 }</summary>
<summary>df.pivot { city }.count { age &gt; 18 }</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
<table class="dataframe" id="df_9"></table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
</details>
<br>
<details>
<summary>df.update { weight }.where { index() &amp;gt; 4 &amp;&amp; city != &quot;Paris&quot; }.with { 50 }</summary>
<summary>df.update { weight }.where { index() &gt; 4 &amp;&amp; city != &quot;Paris&quot; }.with { 50 }</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
<table class="dataframe" id="df_4"></table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
</head>
<body>
<details>
<summary>other.into(&quot;fullName&quot;).cast&amp;lt;Right&amp;gt;()</summary>
<summary>other.into(&quot;fullName&quot;).cast&lt;Right&gt;()</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 3</summary>
<table class="dataframe" id="df_0"></table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
</details>
<br>
<details>
<summary>df.convert { colsAtAnyDepth().colsOf&amp;lt;String&amp;gt;() }.with { it.toCharArray().toList() }</summary>
<summary>df.convert { colsAtAnyDepth().colsOf&lt;String&gt;() }.with { it.toCharArray().toList() }</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
<table class="dataframe" id="df_2"></table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
</head>
<body>
<details>
<summary>df.convert { age }.to&amp;lt;Double&amp;gt;()</summary>
<summary>df.convert { age }.to&lt;Double&gt;()</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
<table class="dataframe" id="df_0"></table>
Expand All @@ -198,7 +198,7 @@
</details>
<br>
<details>
<summary>df.convert { colsOf&amp;lt;Number&amp;gt;() }.to&amp;lt;String&amp;gt;()</summary>
<summary>df.convert { colsOf&lt;Number&gt;() }.to&lt;String&gt;()</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
<table class="dataframe" id="df_2"></table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
</head>
<body>
<details>
<summary>df.fillNulls { colsOf&amp;lt;Int?&amp;gt;() }.with { -1 }</summary>
<summary>df.fillNulls { colsOf&lt;Int?&gt;() }.with { -1 }</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
<table class="dataframe" id="df_0"></table>
Expand All @@ -200,7 +200,7 @@
</details>
<br>
<details>
<summary>df.update { colsOf&amp;lt;Int?&amp;gt;() }.where { it == null }.with { -1 }</summary>
<summary>df.update { colsOf&lt;Int?&gt;() }.where { it == null }.with { -1 }</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
<table class="dataframe" id="df_3"></table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
</details>
<br>
<details>
<summary>pivoted.gather { &quot;London&quot;..&quot;Tokyo&quot; }.cast&amp;lt;Int&amp;gt;().where { it &amp;gt; 0 }.keysInto(&quot;city&quot;)</summary>
<summary>pivoted.gather { &quot;London&quot;..&quot;Tokyo&quot; }.cast&lt;Int&gt;().where { it &gt; 0 }.keysInto(&quot;city&quot;)</summary>
<details>
<summary>Input DataFrame: rowsCount = 6, columnsCount = 9</summary>
<table class="dataframe" id="df_3"></table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
</details>
<br>
<details>
<summary>df.update { colsAtAnyDepth().colsOf&amp;lt;String&amp;gt;() }.with { it.uppercase() }</summary>
<summary>df.update { colsAtAnyDepth().colsOf&lt;String&gt;() }.with { it.uppercase() }</summary>
<details>
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
<table class="dataframe" id="df_3"></table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ val customers: List<Customer> = df.cast<Customer>().toList()

<!---END-->

<!---FUN notebook_test_generate_docs_6-->

## generateCode

```kotlin
Expand Down Expand Up @@ -202,6 +200,8 @@ the generated Kotlin code of `@DataSchema` interfaces and/or extension propertie

### Examples {id="generateCode-examples"}

<!---FUN notebook_test_generate_docs_6-->

```kotlin
df.generateCode("Customer")
```
Expand Down
2 changes: 1 addition & 1 deletion tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ kotlin.sourceSets {
korro {
docs = fileTree(rootProject.rootDir) {
// todo topics/*.md as a part of #898
include("docs/StardustDocs/topics/Utilities-Generation.md")
include("docs/StardustDocs/topics/DataSchema-Data-Classes-Generation.md")
include("docs/StardustDocs/topics/read.md")
include("docs/StardustDocs/topics/write.md")
include("docs/StardustDocs/topics/rename.md")
Expand Down