The XML-RPC server included in drupal core doesn't define the character set that is used to encode the XML.
In our setup a ruby XML-RPC client crashes if the XML document returned by drupal contains German umlauts. The reason is, that drupal uses UTF-8 but the ruby client doesn't realize that.
The issue exists in all drupal versions. I'll provide patches for all versions.
| Comment | File | Size | Author |
|---|---|---|---|
| #62 | interdiff-1774618-61-62.txt | 20.75 KB | fgm |
| #62 | 1774618-xmlrpc_encoding-62.patch | 55.63 KB | fgm |
| #61 | interdiff-1774618-58-61.txt | 966 bytes | fgm |
| #61 | 1774618-xmlrpc_encoding-61.patch | 38.66 KB | fgm |
| #55 | interdiff-1774618-54-55.txt | 22.11 KB | fgm |
Comments
Comment #1
mkalkbrennerPatch for drupal 8.x
Comment #2
mstiem commentedHad a problem with the missing charset definition. My regex on my client crashed often by transmitting ä,ö,ü ect. over XML-RPC. After adding the missing code in XML-RPC everything worked fine.
Comment #3
fgmLooks good to me, but while we're at it we could also fix a long standing issue with some weak old parsers which don't like missing a space between an attribute and a PI termination.
Resetting to CNR to trigger the bot, but otherwise RTBC for me.
Comment #4
mkalkbrennerTest bot succeeded. RTBC
Comment #5
webchickIs it possible to write a test for this?
Also, marking for backport to D7 and D6, per the OP.
Comment #6
mkalkbrennerI'm not yet familiar with tests for Drupal 8 based on Symfony.
There seems to be something appropriate in core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
But other parts of core deal with the same problem. For example the aggregator module:
\n";
// ...
print $output;
}
?>
I didn't find a single test case for the character set!
BTW Any advice how to setup a test that makes sense? Just testing if the headers are set completely doesn't make sense to me. But it would make sense to check if the encoding of the content matches the charset stated in the headers. But that's far more complex.
Comment #7
mkalkbrennerAny feedback?
Comment #8
mkalkbrennerI spent some time on reading through the existing tests and created tests for this issue.
During creating the tests I discovered that not only the XML-RPC server lacks correct definitions of charsets and encodings, but the XML-RPC client has the same issue.
Therefore I extended the patch to fix the XML-RPC client, too.
Comment #9
penyaskitoLooks good to me, just some minor issues in coding standards. Once they are fixed, IMHO it is RTBC.
Nice to have better tests for the XML-RPC clients and server :-)
Remove debug statements not used. There are two of them.
Capital w: "We". And the comment should end with a ".".
Thanks Markus!
Comment #10
mkalkbrennerfixed minor coding standard issues pointed out by penyaskito.
Comment #11
penyaskitoMy comments have been addressed, so catching other's attention.
Comment #12
catchPatch looks good but I think we can drop the custom assertion. Without that, if the test fails, it'll show you what the expected vs. actual value was anyway.
Comment #13
mkalkbrennerOk, I polished the tests.
Comment #14
manumilou commentedPatch backported for 7.x
Comment #15
mkalkbrennerPlease leave the patch RTBC for D8 first.
Comment #16
alexpottHey @mkalkbrenner D8 patch in #13 needs a reroll ... no longer applies
Comment #17
mkalkbrenner#13: 0004-Issue-1774618-XML-RPC-server-does-not-emit-encoding.patch queued for re-testing.
Comment #18
gregglesAfter #1285726-48: Remove XML-RPC moving this to 7.x since it has a patch for that (in #14). It could also go to the contrib xmlrpc first, but I'm not sure.
Comment #23
mkalkbrennerComment #24
fgmThis should now apply, based on the patch in #13, let's see the errors.
Comment #26
fgmIt might look like this : not sure this is the exact equivalent : specifically, I wonder whether the first
assertIdentical()inXmlRpcMessagesTest::testRequestAndResponseEncodingDefinitions()has any chance of failing, ever.Comment #27
fgmComment on the first assert in
XmlRpcMessagesTest::testRequestAndResponseEncodingDefinitions()was not correct. No other change from #26.Comment #29
gábor hojtsyLooks nice to me. Apparently test results did not came back, but https://qa.drupal.org/pifr/test/1099603 shows its green.
Minor: this comment is certainly not true :)
Comment #30
gábor hojtsyFixed that and another minor whitespace.
Comment #35
gábor hojtsyFails are unrelated. So postponing on #2628800: Tests fail on xmlrpc head with invalid !link placeholders..
Comment #36
gábor hojtsyWell, the guzzle fail is not unrelated. We can fix that here, while the !link fail fix is committed from #2628800: Tests fail on xmlrpc head with invalid !link placeholders..
Comment #37
fgmRerolled on current HEAD. One error appears within Guzzle in local tests.
Comment #42
fgmOne of the fails was just a typo, most (all ?) others related to the PSR-7 switch.
Comment #43
gábor hojtsyYay, looks good to me, thanks for the updates. The coverage for setting the charset and for testing it all seems to be adequate. Also getting this in will help with starting the backports to Durpal 7 :)
Comment #44
fgmCommitted to 8.x-1.x HEAD. Thanks all.
Comment #46
gábor hojtsyBackport Drupal 7 anyone? Should we move this issue back to core or open another one?
Comment #50
fgmSame topic, same issue, IMO. But not for tonight.
Comment #51
fgmFirst step : to ease porting and especially later maintenance, test conversion to PSR-4 format. Setting to CNR to trigger bot, but is actually CNW. No actual change besides PSR-4 conversion, so no interdiff.
Comment #54
fgmOops, wrong patch : included renaming our PHP scripts/run-tests.sh to scripts/run-tests.php.
Comment #55
fgmVery rough backport. Not crashing but many fails.
Comment #58
fgmEverything should be fixed except the new encoding test being skipped fo rnow.
Comment #61
fgmForgot one short-form array... when can we require PHP 5.4 on D7 ?
Comment #62
fgmAll tests converted and passing locally, plus a pass of coding standards.
Comment #63
fgmIn case this is not clear, the conversion is finished and awaiting reviews...
Comment #64
gábor hojtsyThese are the key changes, there are a bunch of other misc changes which are bringing the code in line with the Drupal 8 branch I guess. Those do not affect the tests or the issue here, so it would be good to break those out to its own issue IMHO.
For the changes in scope for this patch, I am not sure about the refactoring of the tests to Drupal 8's structure, that is not done in other modules I believe. I can see how it makes backporting fixes easier. Would be great to get committer feedback on it.
Comment #65
fgmBasically, there are indeed 4 main changes here :
Comment #66
gábor hojtsyI think those would be important to break into their own issues, since they make reviewing this change hard.
Comment #67
fgmSplit into 4 child issues and marked postponed on the child issues. We can reactivate it when they're done.