Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix issue while loading a container #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
lookyman merged 1 commit into phpstan:master from jdeniau:patch-1
Mar 11, 2019
Merged

Conversation

Copy link
Contributor

@jdeniau jdeniau commented Mar 5, 2019
edited
Loading

When the URI of the container contains escaped characters like %2F, simplexml_load_file throw an error.

(削除) According to the documentation : (削除ここまで)

(削除) Libxml 2 unescapes the URI, so if you want to pass e.g. b&c as the URI parameter a, you have to call simplexml_load_file(rawurlencode('http://example.com/?a=' . urlencode('b&c'))). Since PHP 5.1.0 you don't need to do this because PHP will do it for you. (削除ここまで)

(削除) I don't understand exactly what should not be done since PHP 5.1.0, but with PHP 7.2, I reproduced the following error : (削除ここまで)

$jd = 'jdjd/test.xml';
$jdSlash = rawurlencode('jdjd/test.xml');
$jnSlash = rawurlencode('jn%2Fjn/test.xml');
$jn = 'jn%2Fjn/test.xml';
var_dump($jd); // string(13) "jdjd/test.xml"
var_dump(simplexml_load_file($jd)); // OK object(SimpleXMLElement) 
var_dump($jdSlash); // string(15) "jdjd%2Ftest.xml"
var_dump(simplexml_load_file($jdSlash)); // OK object(SimpleXMLElement) 
var_dump($jnSlash); // string(20) "jn%252Fjn%2Ftest.xml"
var_dump(simplexml_load_file($jnSlash)); // OK object(SimpleXMLElement)
var_dump($jn); // string(16) "jn%2Fjn/test.xml"
var_dump(simplexml_load_file($jn)); // PHP Warning: simplexml_load_file(): I/O warning : failed to load external entity "jn%2Fjn/test.xml"

Another possible fix is to use:

$xml = @simplexml_load_string(file_get_contents($this->containerXml));

Copy link
Collaborator

lookyman commented Mar 5, 2019

I like the simplexml_load_string solution better. Also, could you add a test for that? Thanks!

When the URI of the container contains escaped characters like `%2F`, `simplexml_load_file` throw an error.
Copy link
Contributor Author

jdeniau commented Mar 5, 2019

@lookyman done

@lookyman lookyman merged commit 649c258 into phpstan:master Mar 11, 2019
Copy link
Collaborator

Thank you!

jdeniau reacted with thumbs up emoji

@jdeniau jdeniau deleted the patch-1 branch March 11, 2019 15:04
@jdeniau jdeniau restored the patch-1 branch March 11, 2019 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /