Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Issue with invalid entry IDs (isPermaLink not set to false) #89

Closed
2 tasks done
glen-84 opened this issue Oct 4, 2018 · 6 comments
Closed
2 tasks done

Issue with invalid entry IDs (isPermaLink not set to false) #89

glen-84 opened this issue Oct 4, 2018 · 6 comments
Labels

Comments

@glen-84
Copy link

glen-84 commented Oct 4, 2018

We're using entry IDs like news-27. Zend\Feed\Uri#isValid is returning true for these IDs, and isPermaLink is therefore not being set to false.

This results in the feed not validating:

line 16, column 19: guid must be a full URL, unless isPermaLink attribute is false: news-27 (10 occurrences) [help]

      <guid>news-27</guid>

Code to reproduce the issue

$entry->setId('news-27');

Expected results

These IDs are not valid URLs, and therefore isPermaLink should be set to false.

Actual results

isPermaLink is not set.

@froschdesign
Copy link
Member

@glen-84

Zend\Feed\Uri#isValid is returning true for these IDs…

Can you provide an unit test which illustrates the problem? At the moment I can not reproduce the problem. Thanks!

@glen-84
Copy link
Author

glen-84 commented Oct 4, 2018

@froschdesign,

What does the following code output for you?

use Zend\Feed\Uri;

var_dump(Uri::factory('news-27')->isValid());

@froschdesign
Copy link
Member

@glen-84
In the meantime, I wanted to write an unit test myself, but there is no test class for Zend\Feed\Uri! I think this should be ported from zend-uri.

I do not know why Atom and RSS are handled differently here:

if (! Uri::factory($this->getDataContainer()->getId())->isValid()
&& ! preg_match(
"#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#",
$this->getDataContainer()->getId()
)
&& ! $this->_validateTagUri($this->getDataContainer()->getId())
) {
throw new Writer\Exception\InvalidArgumentException('Atom 1.0 IDs must be a valid URI/IRI');
}

if (! Uri::factory($this->getDataContainer()->getId())->isValid()) {
$id->setAttribute('isPermaLink', 'false');
}

Btw. the class includes a method isAbsolute which can be help.

@froschdesign
Copy link
Member

@glen-84
Can you test #99? Thanks in advance!

weierophinney added a commit that referenced this issue Mar 5, 2019
Fixes #89 - Issue with invalid entry IDs (isPermaLink not set to false)
@glen-84
Copy link
Author

glen-84 commented Mar 8, 2019

@froschdesign It works! 🎉 Thanks a lot.

(apologies for the late reply)

@froschdesign
Copy link
Member

@glen-84
No problem. Can you look at #90 and give me a feedback?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants