Skip to content
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

[HOTFIX] Validate note name #4632

Merged
merged 6 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static org.apache.zeppelin.scheduler.Job.Status.ABORT;

import java.io.IOException;
import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
Expand Down Expand Up @@ -236,6 +237,12 @@ String normalizeNotePath(String notePath) throws IOException {
}

notePath = notePath.replace("\r", " ").replace("\n", " ");

notePath = URLDecoder.decode(notePath, StandardCharsets.UTF_8.toString());
if (notePath.endsWith("/")) {
throw new IOException("Note name shouldn't end with '/'");
}

int pos = notePath.lastIndexOf("/");
if ((notePath.length() - pos) > 255) {
throw new IOException("Note name must be less than 255");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,5 +528,17 @@ void testNormalizeNotePath() throws IOException {
} catch (IOException e) {
assertEquals("Note name can not contain '..'", e.getMessage());
}
try {
notebookService.normalizeNotePath("%2e%2e/%2e%2e/tmp/test222");
fail("Should fail");
} catch (IOException e) {
assertEquals("Note name can not contain '..'", e.getMessage());
}
try {
notebookService.normalizeNotePath("./");
fail("Should fail");
} catch (IOException e) {
assertEquals("Note name shouldn't end with '/'", e.getMessage());
}
}
}