mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 21:47:59 +01:00
recognize domain characters correctly
This commit is contained in:
parent
9e5d4e02d8
commit
a489d00aed
3 changed files with 12 additions and 3 deletions
|
@ -140,7 +140,7 @@ defmodule Philomena.Images.Image do
|
||||||
|> validate_number(:image_height, greater_than: 0, less_than_or_equal_to: 32767)
|
|> validate_number(:image_height, greater_than: 0, less_than_or_equal_to: 32767)
|
||||||
|> validate_length(:image_name, max: 255, count: :bytes)
|
|> validate_length(:image_name, max: 255, count: :bytes)
|
||||||
|> validate_inclusion(:image_mime_type, ~W(image/gif image/jpeg image/png image/svg+xml video/webm))
|
|> validate_inclusion(:image_mime_type, ~W(image/gif image/jpeg image/png image/svg+xml video/webm))
|
||||||
|> unsafe_validate_unique([:image_sha512_hash], Repo)
|
|> unsafe_validate_unique([:image_orig_sha512_hash], Repo)
|
||||||
end
|
end
|
||||||
|
|
||||||
def source_changeset(image, attrs) do
|
def source_changeset(image, attrs) do
|
||||||
|
|
|
@ -133,6 +133,7 @@ defmodule Textile.Lexer do
|
||||||
string(","),
|
string(","),
|
||||||
string("_") |> concat(choice([space(), eos()])),
|
string("_") |> concat(choice([space(), eos()])),
|
||||||
string("?") |> concat(choice([space(), eos()])),
|
string("?") |> concat(choice([space(), eos()])),
|
||||||
|
string(";") |> concat(choice([space(), eos()])),
|
||||||
space(),
|
space(),
|
||||||
eos()
|
eos()
|
||||||
])
|
])
|
||||||
|
|
|
@ -2,11 +2,19 @@ defmodule Textile.UrlLexer do
|
||||||
import NimbleParsec
|
import NimbleParsec
|
||||||
|
|
||||||
def url_ending_in(ending_sequence) do
|
def url_ending_in(ending_sequence) do
|
||||||
|
domain_character =
|
||||||
|
choice([
|
||||||
|
ascii_char([?a..?z]),
|
||||||
|
ascii_char([?A..?Z]),
|
||||||
|
ascii_char([?0..?9]),
|
||||||
|
string("-")
|
||||||
|
])
|
||||||
|
|
||||||
domain =
|
domain =
|
||||||
repeat(
|
repeat(
|
||||||
choice([
|
choice([
|
||||||
ascii_char([?a..?z]) |> string(".") |> ascii_char([?a..?z]),
|
domain_character |> string(".") |> concat(domain_character),
|
||||||
ascii_char([?a..?z])
|
domain_character
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue