File tree 2 files changed +20
-0
lines changed
main/java/org/apache/zeppelin/service
test/java/org/apache/zeppelin/service 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 24
24
import static org .apache .zeppelin .scheduler .Job .Status .ABORT ;
25
25
26
26
import java .io .IOException ;
27
+ import java .net .URLDecoder ;
28
+ import java .nio .charset .StandardCharsets ;
27
29
import java .text .ParseException ;
28
30
import java .text .SimpleDateFormat ;
29
31
import java .time .Instant ;
@@ -236,6 +238,12 @@ String normalizeNotePath(String notePath) throws IOException {
236
238
}
237
239
238
240
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
+
239
247
int pos = notePath .lastIndexOf ("/" );
240
248
if ((notePath .length () - pos ) > 255 ) {
241
249
throw new IOException ("Note name must be less than 255" );
Original file line number Diff line number Diff line change @@ -528,5 +528,17 @@ void testNormalizeNotePath() throws IOException {
528
528
} catch (IOException e ) {
529
529
assertEquals ("Note name can not contain '..'" , e .getMessage ());
530
530
}
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
+ }
531
543
}
532
544
}
You can’t perform that action at this time.
0 commit comments