Skip to content

Commit 4db76f6

Browse files
fix escaping in iframes
1 parent fe0373c commit 4db76f6

16 files changed

+34
-41
lines changed

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/explainer/PluginCallbackProxy.kt

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -315,26 +315,21 @@ private fun convertToDescription(dataframeLike: Any): String =
315315
}.escapeHtmlForIFrame()
316316

317317
internal fun String.escapeHtmlForIFrame(): String {
318-
val str = this
319318
return buildString {
320-
for (c in str) {
321-
when {
322-
c.code > 127 || c == '\'' || c == '\\' -> {
323-
append("&#")
324-
append(c.code)
325-
append(';')
326-
}
327-
328-
c == '"' -> append(""")
329-
330-
c == '<' -> append("&amp;lt;")
331-
332-
c == '>' -> append("&amp;gt;")
333-
334-
c == '&' -> append("&amp;")
335-
319+
for (c in this@escapeHtmlForIFrame) {
320+
when (c) {
321+
'<' -> append("&lt;")
322+
'>' -> append("&gt;")
323+
'&' -> append("&amp;")
324+
'"' -> append("&quot;")
325+
'\'' -> append("&#39;")
326+
'\\' -> append("&#92;")
336327
else -> {
337-
append(c)
328+
if (c.code > 127) {
329+
append("&#${c.code};")
330+
} else {
331+
append(c)
332+
}
338333
}
339334
}
340335
}

docs/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,3 @@ Code samples for the documentation website reside in [core/.../test/.../samples/
6262
and [tests/.../samples/api](../tests/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api) (for samples can depend on other I/O modules)
6363
and they are copied over to Markdown files in [docs/StardustDocs/topics](./StardustDocs/topics)
6464
by [Korro](https://github.com/devcrocod/korro).
65-
66-

docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectorsMisc.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226
</details>
227227
<br>
228228
<details>
229-
<summary>df.select { colsOf&amp;lt;String&amp;gt;() }</summary>
229+
<summary>df.select { colsOf&lt;String&gt;() }</summary>
230230
<details>
231231
<summary>Input DataFrame: rowsCount = 7, columnsCount = 6</summary>
232232
<table class="dataframe" id="df_6"></table>
@@ -242,7 +242,7 @@
242242
</details>
243243
<br>
244244
<details>
245-
<summary>df.select { colsOf&amp;lt;String?&amp;gt; { it.countDistinct() &amp;gt; 5 } }</summary>
245+
<summary>df.select { colsOf&lt;String?&gt; { it.countDistinct() &gt; 5 } }</summary>
246246
<details>
247247
<summary>Input DataFrame: rowsCount = 7, columnsCount = 6</summary>
248248
<table class="dataframe" id="df_8"></table>
@@ -438,7 +438,7 @@
438438
</details>
439439
<br>
440440
<details>
441-
<summary>df.select { colsAtAnyDepth().colsOf&amp;lt;String&amp;gt;() }</summary>
441+
<summary>df.select { colsAtAnyDepth().colsOf&lt;String&gt;() }</summary>
442442
<details>
443443
<summary>Input DataFrame: rowsCount = 7, columnsCount = 6</summary>
444444
<table class="dataframe" id="df_32"></table>
@@ -454,7 +454,7 @@
454454
</details>
455455
<br>
456456
<details>
457-
<summary>df.select { allExcept { colsOf&amp;lt;String&amp;gt;() } }</summary>
457+
<summary>df.select { allExcept { colsOf&lt;String&gt;() } }</summary>
458458
<details>
459459
<summary>Input DataFrame: rowsCount = 7, columnsCount = 6</summary>
460460
<table class="dataframe" id="df_34"></table>

docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectorsModifySet.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@
274274
</details>
275275
<br>
276276
<details>
277-
<summary>df.select { (colsOf&amp;lt;Int&amp;gt;() and age).distinct() }</summary>
277+
<summary>df.select { (colsOf&lt;Int&gt;() and age).distinct() }</summary>
278278
<details>
279279
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
280280
<table class="dataframe" id="df_12"></table>

docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Access.columnSelectorsUsages.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
</details>
195195
<br>
196196
<details>
197-
<summary>df.fillNaNs { colsAtAnyDepth().colsOf&amp;lt;Double&amp;gt;() }.withZero()</summary>
197+
<summary>df.fillNaNs { colsAtAnyDepth().colsOf&lt;Double&gt;() }.withZero()</summary>
198198
<details>
199199
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
200200
<table class="dataframe" id="df_2"></table>
@@ -270,7 +270,7 @@
270270
</details>
271271
<br>
272272
<details>
273-
<summary>df.gather { colsOf&amp;lt;Number&amp;gt;() }.into(&quot;key&quot;, &quot;value&quot;)</summary>
273+
<summary>df.gather { colsOf&lt;Number&gt;() }.into(&quot;key&quot;, &quot;value&quot;)</summary>
274274
<details>
275275
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
276276
<table class="dataframe" id="df_12"></table>

docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Analyze.columnsFor.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
</head>
179179
<body>
180180
<details>
181-
<summary>df.minFor { colsOf&amp;lt;Int&amp;gt;() }</summary>
181+
<summary>df.minFor { colsOf&lt;Int&gt;() }</summary>
182182
<details>
183183
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
184184
<table class="dataframe" id="df_0"></table>

docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Analyze.countAggregation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
</details>
201201
<br>
202202
<details>
203-
<summary>df.pivot { city }.count { age &amp;gt; 18 }</summary>
203+
<summary>df.pivot { city }.count { age &gt; 18 }</summary>
204204
<details>
205205
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
206206
<table class="dataframe" id="df_9"></table>

docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.DataRowApi.conditions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
</details>
211211
<br>
212212
<details>
213-
<summary>df.update { weight }.where { index() &amp;gt; 4 &amp;&amp; city != &quot;Paris&quot; }.with { 50 }</summary>
213+
<summary>df.update { weight }.where { index() &gt; 4 &amp;&amp; city != &quot;Paris&quot; }.with { 50 }</summary>
214214
<details>
215215
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
216216
<table class="dataframe" id="df_4"></table>

docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Join.joinWithMatch.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
</head>
179179
<body>
180180
<details>
181-
<summary>other.into(&quot;fullName&quot;).cast&amp;lt;Right&amp;gt;()</summary>
181+
<summary>other.into(&quot;fullName&quot;).cast&lt;Right&gt;()</summary>
182182
<details>
183183
<summary>Input DataFrame: rowsCount = 7, columnsCount = 3</summary>
184184
<table class="dataframe" id="df_0"></table>

docs/StardustDocs/resources/snippets/org.jetbrains.kotlinx.dataframe.samples.api.Modify.convert.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
</details>
199199
<br>
200200
<details>
201-
<summary>df.convert { colsAtAnyDepth().colsOf&amp;lt;String&amp;gt;() }.with { it.toCharArray().toList() }</summary>
201+
<summary>df.convert { colsAtAnyDepth().colsOf&lt;String&gt;() }.with { it.toCharArray().toList() }</summary>
202202
<details>
203203
<summary>Input DataFrame: rowsCount = 7, columnsCount = 5</summary>
204204
<table class="dataframe" id="df_2"></table>

0 commit comments

Comments
 (0)