Skip to content

Commit

Permalink
Merge pull request #8457 from krisstern/feat/stable-2.414/backporting…
Browse files Browse the repository at this point in the history
…-2.414.2-1

Backporting for LTS 2.414.2
  • Loading branch information
NotMyFault authored Sep 4, 2023
2 parents 306a489 + 44f9ffc commit 69b23d0
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
import java.io.DataInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.lang.StringEscapeUtils;

/**
* Filters out console notes.
Expand All @@ -36,6 +40,8 @@
*/
public class PlainTextConsoleOutputStream extends LineTransformationOutputStream.Delegating {

private static final Logger LOGGER = Logger.getLogger(PlainTextConsoleOutputStream.class.getName());

/**
*
*/
Expand Down Expand Up @@ -64,7 +70,11 @@ protected void eol(byte[] in, int sz) throws IOException {
int rest = sz - next;
ByteArrayInputStream b = new ByteArrayInputStream(in, next, rest);

ConsoleNote.skip(new DataInputStream(b));
try {
ConsoleNote.skip(new DataInputStream(b));
} catch (IOException x) {
LOGGER.log(Level.FINE, "Failed to skip annotation from \"" + StringEscapeUtils.escapeJava(new String(in, next, rest, Charset.defaultCharset())) + "\"", x);
}

int bytesUsed = rest - b.available(); // bytes consumed by annotations
written += bytesUsed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,5 +869,5 @@ private static OpenOption[] getOpenOptions() {
private static final Logger LOGGER = Logger.getLogger(DirectoryBrowserSupport.class.getName());

@Restricted(NoExternalUse.class)
public static final String DEFAULT_CSP_VALUE = "sandbox; default-src 'none'; img-src 'self'; style-src 'self';";
public static final String DEFAULT_CSP_VALUE = "sandbox allow-same-origin; default-src 'none'; img-src 'self'; style-src 'self';";
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ THE SOFTWARE.
<script src="${resURL}/jsbundles/pages/register.js" type="text/javascript" defer="true" />
</head>
<body class="app-sign-in-register">
<st:include it="${simpleDecorator}" page="simple-header.jelly" optional="true" />
<section class="app-sign-in-register__branding">
<div class="app-sign-in-register__branding__starburst"></div>
<img src="${imagesURL}/svgs/logo.svg" alt="${%logo}"/>
</section>
<main id="main-panel" class="app-sign-in-register__content">
<div class="app-sign-in-register__content-inner">
<h1>${%Register}</h1>

<st:include it="${simpleDecorator}" page="simple-header.jelly" optional="true" />

<template id="i18n" data-strength-strong="${%Strong}"
data-strength-moderate="${%Moderate}"
data-strength-weak="${%Weak}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core">
<section class="app-sign-in-register__branding">
<div class="app-sign-in-register__branding__starburst"></div>
<img src="${imagesURL}/svgs/logo.svg" alt="${%logo}"/>
</section>
</j:jelly>
<j:jelly xmlns:j="jelly:core" />
7 changes: 6 additions & 1 deletion core/src/main/resources/jenkins/model/Jenkins/login.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,16 @@ THE SOFTWARE.
<st:include it="${it.setupWizard}" page="authenticate-security-token"/>
</j:when>
<j:otherwise>
<st:include it="${simpleDecorator}" page="simple-header.jelly" optional="true" />
<section class="app-sign-in-register__branding">
<div class="app-sign-in-register__branding__starburst"></div>
<img src="${imagesURL}/svgs/logo.svg" alt="${%logo}"/>
</section>
<main id="main-panel" class="app-sign-in-register__content">
<div class="app-sign-in-register__content-inner">
<h1>Sign in to Jenkins</h1>

<st:include it="${simpleDecorator}" page="simple-header.jelly" optional="true" />

<form name="login" action="${it.securityRealm.authenticationGatewayUrl}"
method="post">
<j:if test="${error}">
Expand Down
26 changes: 25 additions & 1 deletion test/src/test/java/hudson/console/AnnotatedLargeTextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.matchesRegex;
import static org.junit.Assert.assertEquals;

import hudson.MarkupText;
Expand All @@ -52,7 +53,7 @@ public class AnnotatedLargeTextTest {
public static JenkinsRule r = new JenkinsRule();

@Rule
public LoggerRule logging = new LoggerRule().record(ConsoleAnnotationOutputStream.class, Level.FINE).capture(100);
public LoggerRule logging = new LoggerRule().record(ConsoleAnnotationOutputStream.class, Level.FINE).record(PlainTextConsoleOutputStream.class, Level.FINE).capture(100);

@Test
public void smokes() throws Exception {
Expand Down Expand Up @@ -138,6 +139,29 @@ public void badMac() throws Exception {
+ "AAA\\u001B[0myour home.\\n\"")); // TODO assert that this is IOException: MAC mismatch
}

@Issue("JENKINS-61452")
@Test
public void corruptedNote() throws Exception {
ByteBuffer buf = new ByteBuffer();
PrintStream ps = new PrintStream(buf, true, StandardCharsets.UTF_8);
ps.print("Some text.\n");
ps.print("Go back to " + TestNote.encodeTo("/root", "your home") + ".\n");
ps.print("More text.\n");
String original = buf.toString();
String corrupted = original.replace("+", "\u0000");
buf = new ByteBuffer();
buf.write(corrupted.getBytes());
AnnotatedLargeText<Void> text = new AnnotatedLargeText<>(buf, StandardCharsets.UTF_8, true, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
text.writeLogTo(0, baos);
assertThat(baos.toString(StandardCharsets.UTF_8), matchesRegex("Some text[.]\nGo back to .*your home[.]\nMore text[.]\n"));
assertThat(logging.getMessages(), hasItem(matchesRegex("Failed to skip annotation from .+")));
StringWriter w = new StringWriter();
text.writeHtmlTo(0, w);
assertThat(w.toString(), matchesRegex("Some text[.]\nGo back to .*your home[.]\nMore text[.]\n"));
assertThat(logging.getMessages(), hasItem(matchesRegex("Failed to resurrect annotation from .+")));
}

/** Simplified version of {@link HyperlinkNote}. */
static class TestNote extends ConsoleNote<Void> {
private final String url;
Expand Down
6 changes: 3 additions & 3 deletions war/src/main/scss/abstracts/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ $semantics: (
// Button primary
--button-color--primary: var(--background);
--btn-primary-bg: #063f61;
--btn-primary-bg-hover: lighten(#063f61, 7.5%);
--btn-primary-bg-active: lighten(#063f61, 12%);
// Button primary
--btn-primary-bg-hover: #{lighten(#063f61, 7.5%)};
--btn-primary-bg-active: #{lighten(#063f61, 12%)};
// Deprecated - Button primary
--btn-secondary-color: var(--secondary);
--btn-secondary-bg: var(--btn-text-color);
--btn-secondary-border: var(--medium-grey);
Expand Down

0 comments on commit 69b23d0

Please sign in to comment.