Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
irc_bouncer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lysator
Puppet
irc_bouncer
Commits
1cea229b
Commit
1cea229b
authored
1 year ago
by
Hugo Hörnquist
Browse files
Options
Downloads
Patches
Plain Diff
Introduce percent encoding.
parent
d80975d8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/puppet/functions/percent_escape.rb
+24
-0
24 additions, 0 deletions
lib/puppet/functions/percent_escape.rb
manifests/ident.pp
+6
-7
6 additions, 7 deletions
manifests/ident.pp
with
30 additions
and
7 deletions
lib/puppet/functions/percent_escape.rb
0 → 100644
+
24
−
0
View file @
1cea229b
# frozen_string_literal: true
# @summary Percent encode the given string
#
# Replaces all but the most absic ASCII characters with percent
# encoded bytes. For example, "/Hello" becomes "%2FHello". Note that
# characters encoded with multiple bytes in UTF-8 will become multiple
# bytes.
#
# @see https://en.wikipedia.org/wiki/Percent-encoding
Puppet
::
Functions
.
create_functien
(
:percent_escape
)
do
# @param string
# The string to encode
# @return
# The string percent encoded.
dispatch
:percent
do
param
'String'
,
:string
end
def
percent_escape
(
string
)
safe
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~'
string
.
chars
.
map
{
|
c
|
safe
.
include?
(
c
)
?
c
:
c
.
bytes
.
map
{
|
b
|
"%
#{
b
.
to_s
(
16
)
}
"
}
}.
join
end
end
This diff is collapsed.
Click to expand it.
manifests/ident.pp
+
6
−
7
View file @
1cea229b
...
@@ -26,12 +26,11 @@ class irc_bouncer::ident {
...
@@ -26,12 +26,11 @@ class irc_bouncer::ident {
irc_bouncer::module
{
'identfile'
:
}
irc_bouncer::module
{
'identfile'
:
}
file
{
'/var/lib/znc/moddata/identfile/.registry'
:
file
{
'/var/lib/znc/moddata/identfile/.registry'
:
ensure
=>
present
,
ensure
=>
file
,
# TODO get puppet to escape the string for me
content
=>
[
content
=>
@
(
EOF
)
'File /etc/oidentd.conf'
,
File
%
2
f
;
etc
%
2
f
;
oidentd
%
2
e
;
conf
'Format global { reply "%user%" }'
,
Format
global
%
20
;
%
7
b
;
%
20
;
reply
%
20
;
%
22
;
%
25
;
user
%
25
;
%
22
;
%
20
;
%
7
d
;
''
,
# Trailing newline
|
-
EOF
]
.
map
(
percent_encode
)
.
join
(
"
\n
"
),
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment