Compare commits

...

14 Commits

Author SHA1 Message Date
charles
8abf66781f
Merge b5e518fce4 into a40192dc12 2024-07-27 14:58:24 +08:00
GiteaBot
a40192dc12 [skip ci] Updated translations via Crowdin 2024-07-27 00:27:00 +00:00
Shivaram Lingamneni
e1cf760d2f
OIDC: case-insensitive comparison for auth scheme Basic (#31706)
@kylef pointed out on https://github.com/go-gitea/gitea/pull/31632 that
[RFC7617](https://www.rfc-editor.org/rfc/rfc7617.html#section-2)
mandates case-insensitive comparison of the scheme field `Basic`. #31632
copied a case-sensitive comparison from
https://github.com/go-gitea/gitea/pull/6293. This PR fixes both
comparisons.

The issue only affects OIDC, since the implementation for normal Gitea
endpoints is already correct:


930ca92d7c/services/auth/basic.go (L55-L58)
2024-07-26 19:51:45 +00:00
charles7668
b5e518fce4 Remove 'whitespaces will be removed' message 2024-07-19 19:02:11 +08:00
charles7668
5bd05dee63 Using an error message when the file name is invalid to replace trimming leading and trailing spaces. 2024-07-19 18:59:42 +08:00
charles
ccb9705595 Merge branch 'refs/heads/main' into fix/new-file-space 2024-07-19 13:10:46 +08:00
charles
3d19281d3e Fix processing of .. when using paste. 2024-07-19 12:53:32 +08:00
charles
6071df1bef Prevent the use of '/' with no value. 2024-07-19 12:53:32 +08:00
charles
df0d7c1aec Prevent the query non-space-related warning div. 2024-07-19 11:13:07 +08:00
charles
6d29c32bd3 Change .style.display to showElem and hideElem 2024-07-19 11:08:50 +08:00
charles7668
3cf7472410 Update Warning message 2024-06-30 08:25:53 +08:00
charles7668
2543f15e30 Remove parent path when typing a '..' path. 2024-06-30 07:59:36 +08:00
charles7668
8ddd550e44 Add a check for leading or trailing spaces in the parent directory on the "Add New File" page. 2024-06-30 07:59:36 +08:00
charles
f34a0b9f32 Fix trimming of leading and trailing spaces when adding a new file 2024-06-30 07:59:36 +08:00
4 changed files with 48 additions and 6 deletions

View File

@ -2981,6 +2981,10 @@ emails.not_updated=Falhou a modificação do endereço de email solicitado: %v
emails.duplicate_active=Este endereço de email já está a ser usado por outro utilizador.
emails.change_email_header=Modificar propriedades do email
emails.change_email_text=Tem a certeza que quer modificar este endereço de email?
emails.delete=Eliminar email
emails.delete_desc=Tem a certeza que quer eliminar este endereço de email?
emails.deletion_success=O endereço de email foi eliminado.
emails.delete_primary_email_error=NĂŁo pode eliminar o email principal.
orgs.org_manage_panel=Gestão das organizações
orgs.name=Nome

View File

@ -327,7 +327,7 @@ func getOAuthGroupsForUser(ctx go_context.Context, user *user_model.User) ([]str
func parseBasicAuth(ctx *context.Context) (username, password string, err error) {
authHeader := ctx.Req.Header.Get("Authorization")
if authType, authData, ok := strings.Cut(authHeader, " "); ok && authType == "Basic" {
if authType, authData, ok := strings.Cut(authHeader, " "); ok && strings.EqualFold(authType, "Basic") {
return base.BasicAuthDecode(authData)
}
return "", "", errors.New("invalid basic authentication")
@ -661,7 +661,7 @@ func AccessTokenOAuth(ctx *context.Context) {
// if there is no ClientID or ClientSecret in the request body, fill these fields by the Authorization header and ensure the provided field matches the Authorization header
if form.ClientID == "" || form.ClientSecret == "" {
authHeader := ctx.Req.Header.Get("Authorization")
if authType, authData, ok := strings.Cut(authHeader, " "); ok && authType == "Basic" {
if authType, authData, ok := strings.Cut(authHeader, " "); ok && strings.EqualFold(authType, "Basic") {
clientID, clientSecret, err := base.BasicAuthDecode(authData)
if err != nil {
handleAccessTokenError(ctx, AccessTokenError{

View File

@ -317,7 +317,7 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
case git.EntryModeBlob:
ctx.RenderWithErr(ctx.Tr("repo.editor.directory_is_a_file", fileErr.Path), tplEditFile, &form)
default:
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.RenderWithErr(ctx.Tr("repo.editor.filename_is_invalid", fileErr.Path), tplEditFile, &form)
}
} else {
ctx.Error(http.StatusInternalServerError, err.Error())

View File

@ -75,18 +75,56 @@ export function initRepoEditor() {
}
filenameInput.addEventListener('input', function () {
const parts = filenameInput.value.split('/');
const links = Array.from(document.querySelectorAll('.breadcrumb span.section'));
const dividers = Array.from(document.querySelectorAll('.breadcrumb .breadcrumb-divider'));
if (parts.length > 1) {
let containSpace = false;
for (let i = 0; i < parts.length; ++i) {
const value = parts[i];
const trimValue = value.trim();
if (trimValue === '..') {
// remove previous tree path
if (links.length > 0) {
const link = links.pop();
const divider = dividers.pop();
link.remove();
divider.remove();
}
continue;
}
if (i < parts.length - 1) {
if (value.length) {
$(`<span class="section"><a href="#">${htmlEscape(value)}</a></span>`).insertBefore($(filenameInput));
$('<div class="breadcrumb-divider">/</div>').insertBefore($(filenameInput));
if (trimValue.length) {
const $link = $(`<span class="section"><a href="#">${htmlEscape(value)}</a></span>`);
const $divider = $('<div class="breadcrumb-divider">/</div>');
links.push($link.get(0));
dividers.push($divider.get(0));
$link.insertBefore($(filenameInput));
$divider.insertBefore($(filenameInput));
}
} else {
filenameInput.value = value;
}
this.setSelectionRange(0, 0);
containSpace |= (trimValue !== value && trimValue !== '');
}
let warningDiv = document.querySelector('.ui.warning.message.flash-message.flash-warning.space-related');
containSpace |= Array.from(links).some((link) => {
const value = link.querySelector('a').textContent;
return value.trim() !== value;
});
if (containSpace) {
if (!warningDiv) {
warningDiv = document.createElement('div');
warningDiv.classList.add('ui', 'warning', 'message', 'flash-message', 'flash-warning', 'space-related');
warningDiv.innerHTML = '<p>Parent directory contains leading or trailing whitespace.</p>';
// Add display 'block' because display is set to 'none' in formantic\build\semantic.css
warningDiv.style.display = 'block';
const inputContainer = document.querySelector('.repo-editor-header');
inputContainer.insertAdjacentElement('beforebegin', warningDiv);
}
showElem(warningDiv);
} else if (warningDiv) {
hideElem(warningDiv);
}
}
joinTreePath();