Skip to content

Commit 225be7a

Browse files
committed
Fix field limits in DB and format documents
1 parent 09ed5e9 commit 225be7a

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

lib/backend/parsers/mds_parser.ex

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ defmodule Backend.Parsers.MdsParser do
33

44
def parse(markdown) do
55
args = ["-c", markdown]
6+
67
case System.cmd(@parser_path, args) do
78
{output, 0} -> {:ok, output}
89
{error, status} -> {:error, "Process failed with status #{status}: #{error}"}

lib/backend_web/channels/file_channel.ex

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ defmodule BackendWeb.FileChannel do
2929
{:ok, html} ->
3030
PreviewChannel.send_preview(file_id, html)
3131
Logger.debug("SENT preview BACK ON preview:#{file_id}")
32-
Logger.debug(" HTML Content: #{String.slice(html, 0..100)}...") # Limit log size
32+
# Limit log size
33+
Logger.debug(" HTML Content: #{String.slice(html, 0..100)}...")
3334

3435
{:error, reason} ->
3536
Logger.error("Parser error: #{inspect(reason)}")

mix.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"finch": {:hex, :finch, "0.19.0", "c644641491ea854fc5c1bbaef36bfc764e3f08e7185e1f084e35e0672241b76d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.6.2 or ~> 1.7", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 1.1", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "fc5324ce209125d1e2fa0fcd2634601c52a787aff1cd33ee833664a5af4ea2b6"},
2121
"floki": {:hex, :floki, "0.36.3", "1102f93b16a55bc5383b85ae3ec470f82dee056eaeff9195e8afdf0ef2a43c30", [:mix], [], "hexpm", "fe0158bff509e407735f6d40b3ee0d7deb47f3f3ee7c6c182ad28599f9f6b27a"},
2222
"gettext": {:hex, :gettext, "0.26.2", "5978aa7b21fada6deabf1f6341ddba50bc69c999e812211903b169799208f2a8", [:mix], [{:expo, "~> 0.5.1 or ~> 1.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "aa978504bcf76511efdc22d580ba08e2279caab1066b76bb9aa81c4a1e0a32a5"},
23-
"heroicons": {:git, "https://github.com/tailwindlabs/heroicons.git", "88ab3a0d790e6a47404cba02800a6b25d2afae50", [tag: "v2.1.1", sparse: "optimized"]},
23+
"heroicons": {:git, "https://github.com/tailwindlabs/heroicons.git", "88ab3a0d790e6a47404cba02800a6b25d2afae50", [tag: "v2.1.1", sparse: "optimized", depth: 1]},
2424
"hpax": {:hex, :hpax, "1.0.0", "28dcf54509fe2152a3d040e4e3df5b265dcb6cb532029ecbacf4ce52caea3fd2", [:mix], [], "hexpm", "7f1314731d711e2ca5fdc7fd361296593fc2542570b3105595bb0bc6d0fad601"},
2525
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
2626
"libgraph": {:hex, :libgraph, "0.16.0", "3936f3eca6ef826e08880230f806bfea13193e49bf153f93edcf0239d4fd1d07", [:mix], [], "hexpm", "41ca92240e8a4138c30a7e06466acc709b0cbb795c643e9e17174a178982d6bf"},

priv/repo/migrations/20241129212656_add_file.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule Backend.Repo.Migrations.AddFile do
44
def change do
55
create table(:files) do
66
add :name, :string, null: false
7-
add :content, :string
7+
add :content, :string, size: 10000
88
end
99
end
1010
end

test/backend/mds_parser_test.exs

+8-3
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,22 @@ defmodule Backend.Parsers.MdsParserTest do
1717
test "parses valid content" do
1818
content = "# Test\n\nSome **bold** text"
1919
assert {:ok, html} = MdsParser.parse(content)
20-
assert html =~ "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n</head>\n<body>\n<h1 id=\"0cbc6611f5540bd0809a388dc95a615b\">Test</h1>\n<p>Some <strong>bold</strong> text</p>\n\n</body>\n</html>\n"
20+
21+
assert html =~
22+
"<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n</head>\n<body>\n<h1 id=\"0cbc6611f5540bd0809a388dc95a615b\">Test</h1>\n<p>Some <strong>bold</strong> text</p>\n\n</body>\n</html>\n"
2123
end
2224

2325
test "handles invalid content gracefully" do
2426
content = ""
2527
assert {:ok, html} = MdsParser.parse(content)
26-
assert html =~ "<body>" # Даже пустой контент должен возвращать корректный HTML
28+
29+
# Даже пустой контент должен возвращать корректный HTML
30+
assert html =~ "<body>"
2731
end
2832

2933
test "handles parser errors" do
30-
content = :binary.copy("a", 1_000_000) # Очень длинный ввод для потенциальной ошибки
34+
# Очень длинный ввод для потенциальной ошибки
35+
content = :binary.copy("a", 1_000_000)
3136
assert {:error, _} = MdsParser.parse(content)
3237
end
3338
end

0 commit comments

Comments
 (0)