提交 3f295879 编写于 作者: J Jesse Glick

${h.breakableString(…)} might be called with a null argument if something is broken.

For robustness, pass on the null to Jelly rather than failing page rendering.
上级 87e66570
......@@ -1828,7 +1828,9 @@ public class Functions {
* @since 1.517
*/
public static String breakableString(final String plain) {
if (plain == null) {
return null;
}
return plain.replaceAll("([\\p{Punct}&&[^;]]+\\w)", "<wbr>$1")
.replaceAll("([^\\p{Punct}\\s-]{20})(?=[^\\p{Punct}\\s-]{10})", "$1<wbr>")
;
......
......@@ -36,7 +36,7 @@ import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import jenkins.model.Jenkins;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -322,6 +322,7 @@ public class FunctionsTest {
assertBrokenAs("&lt;&lt;a&lt;bc&lt;def&lt;ghi&lt;", "", "&lt;", "&lt;a", "&lt;bc", "&lt;def", "&lt;ghi", "&lt;");
assertBrokenAs("H,e.l/l:o=w_o+|d", "H", ",e", ".l", "/l", ":o", "=w", "_o", "+|d");
assertBrokenAs("a¶‱ﻷa¶‱ﻷa¶‱ﻷa¶‱ﻷa¶‱ﻷa¶‱ﻷa¶‱ﻷa¶‱ﻷ", "a¶‱ﻷa¶‱ﻷa¶‱ﻷa¶‱ﻷa¶‱ﻷ", "a¶‱ﻷa¶‱ﻷa¶‱ﻷ");
assertNull(Functions.breakableString(null));
}
private void assertBrokenAs(String plain, String... chunks) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册