Skip to content

Commit f025a69

Browse files
jongyoulReamer
andauthored
[HOTFIX] Validate note name (#4632)
* [HOTFIX] Validate note name * [HOTFIX] Validate note name * [HOTFIX] Validate note name * Update zeppelin-server/src/test/java/org/apache/zeppelin/service/NotebookServiceTest.java Co-authored-by: Philipp Dallig <[email protected]> * Update zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java Co-authored-by: Philipp Dallig <[email protected]> * [HOTFIX] Fix commented --------- Co-authored-by: Philipp Dallig <[email protected]>
1 parent df84aff commit f025a69

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

zeppelin-server/src/main/java/org/apache/zeppelin/service/NotebookService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import static org.apache.zeppelin.scheduler.Job.Status.ABORT;
2525

2626
import java.io.IOException;
27+
import java.net.URLDecoder;
28+
import java.nio.charset.StandardCharsets;
2729
import java.text.ParseException;
2830
import java.text.SimpleDateFormat;
2931
import java.time.Instant;
@@ -236,6 +238,12 @@ String normalizeNotePath(String notePath) throws IOException {
236238
}
237239

238240
notePath = notePath.replace("\r", " ").replace("\n", " ");
241+
242+
notePath = URLDecoder.decode(notePath, StandardCharsets.UTF_8.toString());
243+
if (notePath.endsWith("/")) {
244+
throw new IOException("Note name shouldn't end with '/'");
245+
}
246+
239247
int pos = notePath.lastIndexOf("/");
240248
if ((notePath.length() - pos) > 255) {
241249
throw new IOException("Note name must be less than 255");

zeppelin-server/src/test/java/org/apache/zeppelin/service/NotebookServiceTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,5 +528,17 @@ void testNormalizeNotePath() throws IOException {
528528
} catch (IOException e) {
529529
assertEquals("Note name can not contain '..'", e.getMessage());
530530
}
531+
try {
532+
notebookService.normalizeNotePath("%2e%2e/%2e%2e/tmp/test222");
533+
fail("Should fail");
534+
} catch (IOException e) {
535+
assertEquals("Note name can not contain '..'", e.getMessage());
536+
}
537+
try {
538+
notebookService.normalizeNotePath("./");
539+
fail("Should fail");
540+
} catch (IOException e) {
541+
assertEquals("Note name shouldn't end with '/'", e.getMessage());
542+
}
531543
}
532544
}

0 commit comments

Comments
 (0)