Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e773de6e
Commit
e773de6e
authored
Oct 27, 2020
by
Brett Walker
Committed by
Robert Speicher
Oct 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Normalize markdown source during preprocess
to remove UTF8 BOM character
parent
8bd8ea37
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
0 deletions
+73
-0
changelogs/unreleased/20099-markdown-with-yaml-rendering-doesn-t-handle-utf8-bom.yml
...-markdown-with-yaml-rendering-doesn-t-handle-utf8-bom.yml
+5
-0
lib/banzai/filter/normalize_source_filter.rb
lib/banzai/filter/normalize_source_filter.rb
+14
-0
lib/banzai/pipeline/pre_process_pipeline.rb
lib/banzai/pipeline/pre_process_pipeline.rb
+1
-0
spec/lib/banzai/filter/normalize_source_filter_spec.rb
spec/lib/banzai/filter/normalize_source_filter_spec.rb
+26
-0
spec/lib/banzai/pipeline/pre_process_pipeline_spec.rb
spec/lib/banzai/pipeline/pre_process_pipeline_spec.rb
+27
-0
No files found.
changelogs/unreleased/20099-markdown-with-yaml-rendering-doesn-t-handle-utf8-bom.yml
0 → 100644
View file @
e773de6e
---
title
:
Tolerate UTF8 BOM character during frontmatter rendering
merge_request
:
46062
author
:
type
:
fixed
lib/banzai/filter/normalize_source_filter.rb
0 → 100644
View file @
e773de6e
# frozen_string_literal: true
module
Banzai
module
Filter
class
NormalizeSourceFilter
<
HTML
::
Pipeline
::
Filter
UTF8_BOM
=
"
\xEF\xBB\xBF
"
def
call
# Remove UTF8_BOM from beginning of source text
html
.
delete_prefix
(
UTF8_BOM
)
end
end
end
end
lib/banzai/pipeline/pre_process_pipeline.rb
View file @
e773de6e
...
...
@@ -5,6 +5,7 @@ module Banzai
class
PreProcessPipeline
<
BasePipeline
def
self
.
filters
FilterArray
[
Filter
::
NormalizeSourceFilter
,
Filter
::
FrontMatterFilter
,
Filter
::
BlockquoteFenceFilter
,
]
...
...
spec/lib/banzai/filter/normalize_source_filter_spec.rb
0 → 100644
View file @
e773de6e
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Banzai
::
Filter
::
NormalizeSourceFilter
do
include
FilterSpecHelper
it
'removes the UTF8 BOM from the beginning of the text'
do
content
=
"
\xEF\xBB\xBF
---"
output
=
filter
(
content
)
expect
(
output
).
to
match
'---'
end
it
'does not remove those characters from anywhere else in the text'
do
content
=
<<~
MD
\xEF\xBB\xBF
---
\xEF\xBB\xBF
---
MD
output
=
filter
(
content
)
expect
(
output
).
to
match
"---
\n\xEF\xBB\xBF
---
\n
"
end
end
spec/lib/banzai/pipeline/pre_process_pipeline_spec.rb
0 → 100644
View file @
e773de6e
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Banzai
::
Pipeline
::
PreProcessPipeline
do
it
'pre-processes the source text'
do
markdown
=
<<~
MD
\xEF\xBB\xBF
---
foo: :foo_symbol
bar: :bar_symbol
---
>>>
blockquote
>>>
MD
result
=
described_class
.
call
(
markdown
,
{})
aggregate_failures
do
expect
(
result
[
:output
]).
not_to
include
"
\xEF\xBB\xBF
"
expect
(
result
[
:output
]).
not_to
include
'---'
expect
(
result
[
:output
]).
to
include
"```yaml
\n
foo: :foo_symbol
\n
"
expect
(
result
[
:output
]).
to
include
"> blockquote
\n
"
end
end
end
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