Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
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
Container registry
Model registry
Operate
Environments
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
href
pleroma
Commits
39bacba2
Commit
39bacba2
authored
7 years ago
by
lain
Browse files
Options
Downloads
Patches
Plain Diff
More resilient xml parsing.
parent
6935fc3e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/pleroma/web/ostatus/ostatus.ex
+1
-0
1 addition, 0 deletions
lib/pleroma/web/ostatus/ostatus.ex
lib/pleroma/web/web_finger/web_finger.ex
+1
-1
1 addition, 1 deletion
lib/pleroma/web/web_finger/web_finger.ex
lib/pleroma/web/xml/xml.ex
+13
-4
13 additions, 4 deletions
lib/pleroma/web/xml/xml.ex
with
15 additions
and
5 deletions
lib/pleroma/web/ostatus/ostatus.ex
+
1
−
0
View file @
39bacba2
...
...
@@ -30,6 +30,7 @@ def handle_incoming(xml_string) do
activities
=
Enum
.
map
(
entries
,
fn
(
entry
)
->
{
:xmlObj
,
:string
,
object_type
}
=
:xmerl_xpath
.
string
(
'string(/entry/activity:object-type[1])'
,
entry
)
{
:xmlObj
,
:string
,
verb
}
=
:xmerl_xpath
.
string
(
'string(/entry/activity:verb[1])'
,
entry
)
Logger
.
debug
(
"Handling
#{
verb
}
"
)
case
verb
do
'http://activitystrea.ms/schema/1.0/follow'
->
...
...
This diff is collapsed.
Click to expand it.
lib/pleroma/web/web_finger/web_finger.ex
+
1
−
1
View file @
39bacba2
...
...
@@ -98,7 +98,7 @@ def finger(account, getter \\ &@httpoison.get/3) do
end
with
{
:ok
,
%{
status_code:
status_code
,
body:
body
}}
when
status_code
in
200
..
299
<-
response
,
doc
<-
XML
.
parse_document
(
body
),
doc
when
doc
!=
:error
<-
XML
.
parse_document
(
body
),
{
:ok
,
data
}
<-
webfinger_from_xml
(
doc
)
do
{
:ok
,
data
}
else
...
...
This diff is collapsed.
Click to expand it.
lib/pleroma/web/xml/xml.ex
+
13
−
4
View file @
39bacba2
defmodule
Pleroma
.
Web
.
XML
do
require
Logger
def
string_from_xpath
(
xpath
,
:error
),
do
:
nil
def
string_from_xpath
(
xpath
,
doc
)
do
{
:xmlObj
,
:string
,
res
}
=
:xmerl_xpath
.
string
(
'string(
#{
xpath
}
)'
,
doc
)
...
...
@@ -10,10 +13,16 @@ def string_from_xpath(xpath, doc) do
end
def
parse_document
(
text
)
do
{
doc
,
_rest
}
=
text
|>
:binary
.
bin_to_list
|>
:xmerl_scan
.
string
try
do
{
doc
,
_rest
}
=
text
|>
:binary
.
bin_to_list
|>
:xmerl_scan
.
string
doc
doc
catch
:exit
,
error
->
Logger
.
debug
(
"Couldn't parse xml:
#{
inspect
(
text
)
}
"
)
:error
end
end
end
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