mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 06:11:26 +00:00
* Make webfinger case insensitive * Make webfinger case insensitive * Case insensitive domain name * Case-insensitive webfinger * formatting Co-authored-by: Kradyz <k@radiz.nl>
This commit is contained in:
parent
c883a49a40
commit
9f64872d5a
6 changed files with 10 additions and 4 deletions
|
@ -649,7 +649,7 @@ export function wrapper(form: any): string {
|
||||||
|
|
||||||
export function randomString(length: number): string {
|
export function randomString(length: number): string {
|
||||||
var result = '';
|
var result = '';
|
||||||
var characters = 'abcdefghijklmnopqrstuvwxyz0123456789_';
|
var characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_';
|
||||||
var charactersLength = characters.length;
|
var charactersLength = characters.length;
|
||||||
for (var i = 0; i < length; i++) {
|
for (var i = 0; i < length; i++) {
|
||||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||||
|
|
|
@ -8,6 +8,8 @@ homepage = "https://join-lemmy.org/"
|
||||||
documentation = "https://join-lemmy.org/docs/en/index.html"
|
documentation = "https://join-lemmy.org/docs/en/index.html"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
name = "lemmy_db_schema"
|
||||||
|
path = "src/lib.rs"
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
|
functions::lower,
|
||||||
naive_now,
|
naive_now,
|
||||||
newtypes::{CommunityId, DbUrl, PersonId},
|
newtypes::{CommunityId, DbUrl, PersonId},
|
||||||
source::community::{
|
source::community::{
|
||||||
|
@ -95,7 +96,7 @@ impl Community {
|
||||||
use crate::schema::community::dsl::*;
|
use crate::schema::community::dsl::*;
|
||||||
community
|
community
|
||||||
.filter(local.eq(true))
|
.filter(local.eq(true))
|
||||||
.filter(name.eq(community_name))
|
.filter(lower(name).eq(lower(community_name)))
|
||||||
.first::<Self>(conn)
|
.first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
|
functions::lower,
|
||||||
naive_now,
|
naive_now,
|
||||||
newtypes::{DbUrl, PersonId},
|
newtypes::{DbUrl, PersonId},
|
||||||
schema::person::dsl::*,
|
schema::person::dsl::*,
|
||||||
|
@ -194,7 +195,7 @@ impl Person {
|
||||||
person
|
person
|
||||||
.filter(deleted.eq(false))
|
.filter(deleted.eq(false))
|
||||||
.filter(local.eq(true))
|
.filter(local.eq(true))
|
||||||
.filter(name.eq(from_name))
|
.filter(lower(name).eq(lower(from_name)))
|
||||||
.first::<Person>(conn)
|
.first::<Person>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,8 @@ pub mod functions {
|
||||||
sql_function! {
|
sql_function! {
|
||||||
fn hot_rank(score: BigInt, time: Timestamp) -> Integer;
|
fn hot_rank(score: BigInt, time: Timestamp) -> Integer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sql_function!(fn lower(x: Text) -> Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -13,7 +13,7 @@ static SETTINGS: Lazy<RwLock<Settings>> =
|
||||||
Lazy::new(|| RwLock::new(Settings::init().expect("Failed to load settings file")));
|
Lazy::new(|| RwLock::new(Settings::init().expect("Failed to load settings file")));
|
||||||
static WEBFINGER_REGEX: Lazy<Regex> = Lazy::new(|| {
|
static WEBFINGER_REGEX: Lazy<Regex> = Lazy::new(|| {
|
||||||
Regex::new(&format!(
|
Regex::new(&format!(
|
||||||
"^acct:([a-z0-9_]{{3,}})@{}$",
|
"^acct:([a-zA-Z0-9_]{{3,}})@{}$",
|
||||||
Settings::get().hostname
|
Settings::get().hostname
|
||||||
))
|
))
|
||||||
.expect("compile webfinger regex")
|
.expect("compile webfinger regex")
|
||||||
|
|
Loading…
Reference in a new issue