@@ -0,0 +1,2932 @@
+/*%0A * The MIT License%0A *%0A * Copyright (c) 2019 CloudBees, Inc.%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining a copy%0A * of this software and associated documentation files (the %22Software%22), to deal%0A * in the Software without restriction, including without limitation the rights%0A * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0A * copies of the Software, and to permit persons to whom the Software is%0A * furnished to do so, subject to the following conditions:%0A *%0A * The above copyright notice and this permission notice shall be included in%0A * all copies or substantial portions of the Software.%0A *%0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0A * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0A * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN%0A * THE SOFTWARE.%0A */%0A%0Apackage org.jenkinsci.plugins.credentialsbinding.masking;%0A%0Aimport hudson.Extension;%0Aimport org.kohsuke.accmod.Restricted;%0Aimport org.kohsuke.accmod.restrictions.NoExternalUse;%0A%0Aimport javax.annotation.Nonnull;%0Aimport java.util.Collection;%0Aimport java.util.Collections;%0A%0A/**%0A * Almquist shell, aka ash, is the default shell in Alpine distribution%0A */%0A@Extension%0A@Restricted(NoExternalUse.class)%0Apublic class AlmquistShellSecretPatternFactory implements SecretPatternFactory %7B%0A%0A    private static final char SINGLE_QUOTE = '%5C'';%0A    private static final String START_FRAGMENT = %22'%5C%22%22;%0A    private static final String END_FRAGMENT = %22%5C%22'%22;%0A%0A    private @Nonnull String getQuotedForm(@Nonnull String input) %7B%0A        StringBuilder sb = new StringBuilder(input.length());%0A        for (int i = 0; i %3C input.length(); i++) %7B%0A            char c = input.charAt(i);%0A            if (c == SINGLE_QUOTE) %7B%0A                // a single quote is replaced by '%22'%22' which is the concatenation of%0A                // '%5Bpart before...%5D' + %22'%22 + '%5B...part after%5D'%0A                // if there are multiple single quotes successively, they are included in the double quotes together%0A                sb.append(START_FRAGMENT);%0A                // the first one, at index i%0A                sb.append(SINGLE_QUOTE);%0A                for (int j = i + 1; j %3C input.length() && input.charAt(j) == SINGLE_QUOTE; j++) %7B%0A                    sb.append(SINGLE_QUOTE);%0A                    i++;%0A                %7D%0A                sb.append(END_FRAGMENT);%0A            %7D else %7B%0A                sb.append(c);%0A            %7D%0A        %7D%0A        return sb.toString();%0A    %7D%0A%0A    @Override%0A    public @Nonnull Collection%3CString%3E getEncodedForms(@Nonnull String input) %7B%0A        return Collections.singleton(getQuotedForm(input));%0A    %7D%0A%7D%0A

Add support for Almquist shell in masking