Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Feeds
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MickGe
Feeds
Commits
31bd6f76
Commit
31bd6f76
authored
11 years ago
by
Andrew Dolgov
Browse files
Options
Downloads
Patches
Plain Diff
parser: trim some some feed-extracted data link titles and links
parent
4ce77867
No related branches found
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
classes/feeditem/atom.php
+5
-5
5 additions, 5 deletions
classes/feeditem/atom.php
classes/feeditem/rss.php
+6
-6
6 additions, 6 deletions
classes/feeditem/rss.php
classes/feedparser.php
+6
-2
6 additions, 2 deletions
classes/feedparser.php
with
17 additions
and
13 deletions
classes/feeditem/atom.php
+
5
−
5
View file @
31bd6f76
...
@@ -43,9 +43,9 @@ class FeedItem_Atom extends FeedItem_Common {
...
@@ -43,9 +43,9 @@ class FeedItem_Atom extends FeedItem_Common {
$base
=
$this
->
xpath
->
evaluate
(
"string(ancestor-or-self::*[@xml:base][1]/@xml:base)"
,
$link
);
$base
=
$this
->
xpath
->
evaluate
(
"string(ancestor-or-self::*[@xml:base][1]/@xml:base)"
,
$link
);
if
(
$base
)
if
(
$base
)
return
rewrite_relative_url
(
$base
,
$link
->
getAttribute
(
"href"
));
return
rewrite_relative_url
(
$base
,
trim
(
$link
->
getAttribute
(
"href"
))
)
;
else
else
return
$link
->
getAttribute
(
"href"
);
return
trim
(
$link
->
getAttribute
(
"href"
)
)
;
}
}
}
}
...
@@ -55,7 +55,7 @@ class FeedItem_Atom extends FeedItem_Common {
...
@@ -55,7 +55,7 @@ class FeedItem_Atom extends FeedItem_Common {
$title
=
$this
->
elem
->
getElementsByTagName
(
"title"
)
->
item
(
0
);
$title
=
$this
->
elem
->
getElementsByTagName
(
"title"
)
->
item
(
0
);
if
(
$title
)
{
if
(
$title
)
{
return
$title
->
nodeValue
;
return
trim
(
$title
->
nodeValue
)
;
}
}
}
}
...
@@ -106,13 +106,13 @@ class FeedItem_Atom extends FeedItem_Common {
...
@@ -106,13 +106,13 @@ class FeedItem_Atom extends FeedItem_Common {
foreach
(
$categories
as
$cat
)
{
foreach
(
$categories
as
$cat
)
{
if
(
$cat
->
hasAttribute
(
"term"
))
if
(
$cat
->
hasAttribute
(
"term"
))
array_push
(
$cats
,
$cat
->
getAttribute
(
"term"
));
array_push
(
$cats
,
trim
(
$cat
->
getAttribute
(
"term"
))
)
;
}
}
$categories
=
$this
->
xpath
->
query
(
"dc:subject"
,
$this
->
elem
);
$categories
=
$this
->
xpath
->
query
(
"dc:subject"
,
$this
->
elem
);
foreach
(
$categories
as
$cat
)
{
foreach
(
$categories
as
$cat
)
{
array_push
(
$cats
,
$cat
->
nodeValue
);
array_push
(
$cats
,
trim
(
$cat
->
nodeValue
)
)
;
}
}
return
$cats
;
return
$cats
;
...
...
This diff is collapsed.
Click to expand it.
classes/feeditem/rss.php
+
6
−
6
View file @
31bd6f76
...
@@ -33,20 +33,20 @@ class FeedItem_RSS extends FeedItem_Common {
...
@@ -33,20 +33,20 @@ class FeedItem_RSS extends FeedItem_Common {
||
$link
->
getAttribute
(
"rel"
)
==
"alternate"
||
$link
->
getAttribute
(
"rel"
)
==
"alternate"
||
$link
->
getAttribute
(
"rel"
)
==
"standout"
))
{
||
$link
->
getAttribute
(
"rel"
)
==
"standout"
))
{
return
$link
->
getAttribute
(
"href"
);
return
trim
(
$link
->
getAttribute
(
"href"
)
)
;
}
}
}
}
$link
=
$this
->
elem
->
getElementsByTagName
(
"guid"
)
->
item
(
0
);
$link
=
$this
->
elem
->
getElementsByTagName
(
"guid"
)
->
item
(
0
);
if
(
$link
&&
$link
->
hasAttributes
()
&&
$link
->
getAttribute
(
"isPermaLink"
)
==
"true"
)
{
if
(
$link
&&
$link
->
hasAttributes
()
&&
$link
->
getAttribute
(
"isPermaLink"
)
==
"true"
)
{
return
$link
->
nodeValue
;
return
trim
(
$link
->
nodeValue
)
;
}
}
$link
=
$this
->
elem
->
getElementsByTagName
(
"link"
)
->
item
(
0
);
$link
=
$this
->
elem
->
getElementsByTagName
(
"link"
)
->
item
(
0
);
if
(
$link
)
{
if
(
$link
)
{
return
$link
->
nodeValue
;
return
trim
(
$link
->
nodeValue
)
;
}
}
}
}
...
@@ -54,7 +54,7 @@ class FeedItem_RSS extends FeedItem_Common {
...
@@ -54,7 +54,7 @@ class FeedItem_RSS extends FeedItem_Common {
$title
=
$this
->
elem
->
getElementsByTagName
(
"title"
)
->
item
(
0
);
$title
=
$this
->
elem
->
getElementsByTagName
(
"title"
)
->
item
(
0
);
if
(
$title
)
{
if
(
$title
)
{
return
$title
->
nodeValue
;
return
trim
(
$title
->
nodeValue
)
;
}
}
}
}
...
@@ -90,13 +90,13 @@ class FeedItem_RSS extends FeedItem_Common {
...
@@ -90,13 +90,13 @@ class FeedItem_RSS extends FeedItem_Common {
$cats
=
array
();
$cats
=
array
();
foreach
(
$categories
as
$cat
)
{
foreach
(
$categories
as
$cat
)
{
array_push
(
$cats
,
$cat
->
nodeValue
);
array_push
(
$cats
,
trim
(
$cat
->
nodeValue
)
)
;
}
}
$categories
=
$this
->
xpath
->
query
(
"dc:subject"
,
$this
->
elem
);
$categories
=
$this
->
xpath
->
query
(
"dc:subject"
,
$this
->
elem
);
foreach
(
$categories
as
$cat
)
{
foreach
(
$categories
as
$cat
)
{
array_push
(
$cats
,
$cat
->
nodeValue
);
array_push
(
$cats
,
trim
(
$cat
->
nodeValue
)
)
;
}
}
return
$cats
;
return
$cats
;
...
...
This diff is collapsed.
Click to expand it.
classes/feedparser.php
+
6
−
2
View file @
31bd6f76
...
@@ -205,6 +205,10 @@ class FeedParser {
...
@@ -205,6 +205,10 @@ class FeedParser {
break
;
break
;
}
}
if
(
$this
->
title
)
$this
->
title
=
trim
(
$this
->
title
);
if
(
$this
->
link
)
$this
->
link
=
trim
(
$this
->
link
);
}
else
{
}
else
{
if
(
!
isset
(
$this
->
error
)
){
if
(
!
isset
(
$this
->
error
)
){
$this
->
error
=
"Unknown/unsupported feed type"
;
$this
->
error
=
"Unknown/unsupported feed type"
;
...
@@ -252,7 +256,7 @@ class FeedParser {
...
@@ -252,7 +256,7 @@ class FeedParser {
foreach
(
$links
as
$link
)
{
foreach
(
$links
as
$link
)
{
if
(
!
$rel
||
$link
->
hasAttribute
(
'rel'
)
&&
$link
->
getAttribute
(
'rel'
)
==
$rel
)
{
if
(
!
$rel
||
$link
->
hasAttribute
(
'rel'
)
&&
$link
->
getAttribute
(
'rel'
)
==
$rel
)
{
array_push
(
$rv
,
$link
->
getAttribute
(
'href'
));
array_push
(
$rv
,
trim
(
$link
->
getAttribute
(
'href'
))
)
;
}
}
}
}
break
;
break
;
...
@@ -261,7 +265,7 @@ class FeedParser {
...
@@ -261,7 +265,7 @@ class FeedParser {
foreach
(
$links
as
$link
)
{
foreach
(
$links
as
$link
)
{
if
(
!
$rel
||
$link
->
hasAttribute
(
'rel'
)
&&
$link
->
getAttribute
(
'rel'
)
==
$rel
)
{
if
(
!
$rel
||
$link
->
hasAttribute
(
'rel'
)
&&
$link
->
getAttribute
(
'rel'
)
==
$rel
)
{
array_push
(
$rv
,
$link
->
getAttribute
(
'href'
));
array_push
(
$rv
,
trim
(
$link
->
getAttribute
(
'href'
))
)
;
}
}
}
}
break
;
break
;
...
...
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