Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
dc5d8dde
Unverified
Commit
dc5d8dde
authored
Apr 03, 2022
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: handle page metadata parse failure
parent
05b40539
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
24 deletions
+28
-24
pages.js
server/models/pages.js
+28
-24
No files found.
server/models/pages.js
View file @
dc5d8dde
...
...
@@ -192,35 +192,39 @@ module.exports = class Page extends Model {
*/
static
parseMetadata
(
raw
,
contentType
)
{
let
result
switch
(
contentType
)
{
case
'markdown'
:
result
=
frontmatterRegex
.
markdown
.
exec
(
raw
)
if
(
result
[
2
])
{
return
{
...
yaml
.
safeLoad
(
result
[
2
]),
content
:
result
[
3
]
}
}
else
{
// Attempt legacy v1 format
result
=
frontmatterRegex
.
legacy
.
exec
(
raw
)
try
{
switch
(
contentType
)
{
case
'markdown'
:
result
=
frontmatterRegex
.
markdown
.
exec
(
raw
)
if
(
result
[
2
])
{
return
{
title
:
result
[
2
],
description
:
result
[
4
],
content
:
result
[
5
]
...
yaml
.
safeLoad
(
result
[
2
]),
content
:
result
[
3
]
}
}
else
{
// Attempt legacy v1 format
result
=
frontmatterRegex
.
legacy
.
exec
(
raw
)
if
(
result
[
2
])
{
return
{
title
:
result
[
2
],
description
:
result
[
4
],
content
:
result
[
5
]
}
}
}
}
break
case
'html'
:
result
=
frontmatterRegex
.
html
.
exec
(
raw
)
if
(
result
[
2
])
{
return
{
...
yaml
.
safeLoad
(
result
[
2
]),
content
:
result
[
3
]
break
case
'html'
:
result
=
frontmatterRegex
.
html
.
exec
(
raw
)
if
(
result
[
2
])
{
return
{
...
yaml
.
safeLoad
(
result
[
2
]),
content
:
result
[
3
]
}
}
}
break
break
}
}
catch
(
err
)
{
WIKI
.
logger
.
warn
(
'Failed to parse page metadata. Invalid syntax.'
)
}
return
{
content
:
raw
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment