Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
currently, drupal_get_message() in common.inc does this:
$response = preg_split("/\r\n|\n|\r/", $response);
...
$result->data = implode('', $response);
This is bad news, particularly for parsing xml.
It can make valid xml be invalid, in the case where and eol character is the sole white
space separator. My fix is to do this:
implode("\n", $response);
Comment | File | Size | Author |
---|---|---|---|
#5 | drupal-http.diff | 1.37 KB | Kjartan |
Comments
Comment #1
mda-1 CreditAttribution: mda-1 commentedSorry, i meant drupal_http_request not drupal_get_message
Comment #2
mda-1 CreditAttribution: mda-1 commentedThe above fix still does not preserve the original body. Here is a fix that does.
$orig_response = $response;
$response = preg_split("/\r\n|\n|\r/", $response);
...
$result->data = preg_replace("/^.*?\015\012\015\012/s", '', $orig_response);
Comment #3
mda-1 CreditAttribution: mda-1 commentedComment #4
Dries CreditAttribution: Dries commentedPlease attach a patch instead.
Comment #5
Kjartan CreditAttribution: Kjartan commentedThis patch should leave the original data alone and just extract the headers.
Comment #6
Dries CreditAttribution: Dries commentedCommitted to HEAD and DRUPAL-4-4. Thanks.
Comment #7
moazam CreditAttribution: moazam commentedI've applied this patch to my 4.4.1 distribution but the problem is still not fixed.
For example, if you look at this feed:
http://blogs.sun.com/roller/rss/tucker
The RSS feed is fine and the content is fine...but when Drupal reads it
over, it screws up the text. "How we're" becomes "Howwe're" and "create
an" becomes "createan".
From discussing with Todd Dailey, this is happening because there are hard returns in the feed. "So, drupal is taking "how(hard return)we're" and turning it into "howwe're"." (Todd).
I currently have an example of this at www.unixville.com. Look at the feed which is titled "On opening up Solaris".
This behavior can be seen when using the "Blog It" feature and also when
using the general "News Aggregator" page. I currently have filters set to
OFF (Do Not Filter). I see the same behavior even if I set filters to
"Strip Tags" or "Escape Tags".
Comment #8
mda-1 CreditAttribution: mda-1 commentedhave you deleted the existing items from the feed in your drupal?
do a "remove items" then an "update items".
i can read that feed fine in my patched version.
-mda
Comment #9
moazam CreditAttribution: moazam commentedmda, you're the man! It all worked and actually fixed another problem I was having with munged href links! Thanks a million.
-Moazam
Comment #10
(not verified) CreditAttribution: commented