Skip to content

[Translation] [Config] Clear libxml errors after parsing xliff file #11908

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
merged 1 commit into from
Sep 23, 2014

Conversation

pulzarraider
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

If libxml_use_internal_errors is set to true before parsing xliff file, the libxml errors are not cleared correctly. An error Validation failed: no DTD found ! occurs in libxml errors after parsing and it's available outside the xliff parser (can break other functionality that use libxml_get_errors function).

@@ -39,6 +54,7 @@ public function testLoadWithResname()
$catalogue = $loader->load(__DIR__.'/../fixtures/resname.xlf', 'en', 'domain1');

$this->assertEquals(array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'foo'), $catalogue->all('domain1'));
$this->assertEquals(array(), libxml_get_errors());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the following two cases don't need asserting errors are empty. It is a duplicataction of the preceeding test cases and not really related to these ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks.

@pulzarraider pulzarraider changed the title [WIP][Translation] Clear libxml errors after parsing xliff file [Translation] Clear libxml errors after parsing xliff file Sep 11, 2014
@jakzal
Copy link
Contributor

jakzal commented Sep 11, 2014

Actually, I think it's solved in a wrong place. The errors are coming from XmlUtils::loadFile(). That's where libxml_clear_errors() should be called.

@stof
Copy link
Member

stof commented Sep 12, 2014

I agree with @jakzal that XmlUtils needs the same fix.

However, the fix is indeed needed in this loader as it also performs some additional XML formatting

@pulzarraider
Copy link
Contributor Author

Thank you @jakzal @stof. I will create another PR to fix XmlUtils, too.

@stof
Copy link
Member

stof commented Sep 12, 2014

@pulzarraider you can put it in the same PR

@pulzarraider
Copy link
Contributor Author

@stof ok

@jakzal
Copy link
Contributor

jakzal commented Sep 12, 2014

@pulzarraider can you standarize the order of calling libxml_use_internal_errors($internalErrors); and libxml_clear_errors();? These two are called in two places in a different order. Call me pedantic, but it bothers me a bit :P

$this->assertEquals(array(), libxml_get_errors());
}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need for two blank lines.

@fabpot
Copy link
Member

fabpot commented Sep 22, 2014

@pulzarraider Do you have some time in the coming days to finish this PR?

@pulzarraider
Copy link
Contributor Author

@fabpot yes, I will finish it today evening.

@fabpot
Copy link
Member

fabpot commented Sep 22, 2014

@pulzarraider Great! Thank you very much.

@pulzarraider
Copy link
Contributor Author

@fabpot Glad I could help.

@jakzal @stof @xabbuh Thank you for your comments to make this PR better.

@pulzarraider pulzarraider changed the title [Translation] Clear libxml errors after parsing xliff file [Translation] [Config] Clear libxml errors after parsing xliff file Sep 22, 2014
@fabpot
Copy link
Member

fabpot commented Sep 22, 2014

👍

1 similar comment
@jakzal
Copy link
Contributor

jakzal commented Sep 22, 2014

👍

@fabpot
Copy link
Member

fabpot commented Sep 23, 2014

Thank you @pulzarraider.

@fabpot fabpot merged commit fab61ef into symfony:2.3 Sep 23, 2014
fabpot added a commit that referenced this pull request Sep 23, 2014
…liff file (pulzarraider)

This PR was merged into the 2.3 branch.

Discussion
----------

[Translation] [Config] Clear libxml errors after parsing xliff file

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

If libxml_use_internal_errors is set to `true` before parsing xliff file, the libxml errors are not cleared correctly. An error `Validation failed: no DTD found !` occurs in libxml errors after parsing and it's available outside the xliff parser (can break other functionality that use `libxml_get_errors` function).

Commits
-------

fab61ef [Translation] [Config] Clear libxml errors after parsing XML file
@pulzarraider pulzarraider deleted the xliff_fix branch September 27, 2014 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy