2012-02-01 114 views
2

有人能告訴我爲什麼這個字符串不會反序列化嗎?我已經試過的一切(的stripslashes,和addslashes,修剪,等等...)不能反序列化字符串

a:10:{s:8:"order_id";s:13:"9006710350464";s:5:"buyer";s:10:"1303912674";s:3:"app";s:15:"223615011031939";s:8:"receiver";s:10:"1303912674";s:6:"amount";s:2:"20";s:11:"time_placed";s:10:"1326235812";s:11:"update_time";s:10:"1326235818";s:4:"data";s:0:"";s:5:"items";a:1:{i:0;a:7:{s:7:"item_id";s:4:"1_48";s:5:"title";s:49:"I\'m Not Jesus Mommy (Full Movie) - 48 Hour Stream";s:11:"description";s:204:"This is a purcahse to watch I\'m Not Jesus Mommy on FilmDemic Movie Streaming for a period of 48 hours. Once you complete the purchase, your account will have access to watch the movie for up to 48 hours.";s:9:"image_url";s:144:"https://filmdemic.com/apps/fb-streaming/wp-main/wp-content/themes/fd-fb-stream-wpf-child/library/images/titles/slidersize/im_not_jesus_mommy.jpg";s:11:"product_url";s:46:"http://filmdemic.com/apps/fb-streaming/film-1";s:5:"price";s:2:"20";s:4:"data";s:37:"film_id=1&wp_user_id=4&view_length=48";}}s:6:"status";s:6:"placed";} 

我得到「錯誤的偏移量370 952個字節」,但這並沒有什麼意義,「米「在Stream中是第370個字節。

謝謝!

+0

請將您的帖子中的代碼顯示爲實際代碼,而不是純文本。序列化數據的未格式化的怪異性使我甚至不願意試圖回答你的問題。 – rdlowrey 2012-02-01 19:07:55

+1

@rdlowrey他的問題是關於反序列化不良數據......這不是關於代碼。如果你不能看到數據,你怎麼修復一個有關格式不正確的序列化數據的錯誤... – 2012-02-01 19:10:17

+0

[PHP Unserialize Offset Error]的可能重複(http://stackoverflow.com/questions/3199491/php-unserialize-偏移錯誤) - 您的序列化字符串已損壞。 – hakre 2012-02-01 19:13:27

回答

3

在位置324處不應該存在斜槓。在PHP中序列化數據使用字符計數。例如:

s:49:"I\'m Not Jesus Mommy (Full Movie) - 48 Hour Stream" 

表示將會有一串49個字符出現在下面的引號中。但是如果你計算正確的話,在這個字符串中有一個「50」字符。如果你試圖逃避它,請不要通過它來解決你的問題。

在位置844修復這個問題後,似乎還有另一個錯誤,即product_url的結尾,它似乎缺少一個字符,可能是url中的尾部斜槓,因爲url長度爲45個字符,但它是期待一個46字符長的網址...

所以可以矯正你的串行數據後,我得到這個:

一:10:{S:8: 「ORDER_ID」; S:13: 「9006710350464」 S:5: 「買方」; S:10: 「1303912674」; S:3: 「應用程序」,S:15: 「223615011031939」; S:8: 「接收器」; S:10: 「1303912674」; S: 6: 「量」; S:2: 「20」; S:11: 「time_placed」; S:10: 「1326235812」; S:11: 「UPDATE_TIME」; S:10: 「1326235818」; S:4: 「數據」; S:0: 「」,S:5 : 「項目」;一個:1:{I:0;一個:7:{S:7: 「ITEM_ID」; S:4: 「1_48」; S:5: 「標題」,S:49:「我電影中的耶穌媽媽一段時間沒有耶穌媽媽(全電影) - 48小時 流的「; s:11:」描述「; s:204:」這是一個看我不是 48小時。 完成購買後,您的帳戶將可以觀看 電影,最長可播放48小時。「; s:9:」image_url「; s:144:」https://filmdemic.com/apps/fb -streaming/WP-主/可溼性粉劑內容/主題/ FD-FB-流WPF的孩子/庫/圖像/標題/ slidersize/im_not_jesus_mommy.jpg 「; S:11:」 product_url 「; S:46:」 HTTP ://filmdemic.com/apps/fb-streaming/film-1/ 「; S:5:」 價格 「S:2:」 20 「; S:4:」 數據 「; S:37:」 film_id = 1 & wp_user_id = 4 & view_length = 48 「;}} S:6:」 狀態 「; S:6:」 放置「;}

並且它導致成

array (
    'order_id' => '9006710350464', 
    'buyer' => '1303912674', 
    'app' => '223615011031939', 
    'receiver' => '1303912674', 
    'amount' => '20', 
    'time_placed' => '1326235812', 
    'update_time' => '1326235818', 
    'data' => '', 
    'items' => 
    array (
    0 => 
    array (
     'item_id' => '1_48', 
     'title' => 'I'm Not Jesus Mommy (Full Movie) - 48 Hour Stream', 
     'description' => 'This is a purcahse to watch I\'m Not Jesus Mommy on FilmDemic Movie Streaming for a period of 48 hours. Once you complete the purchase, your account will have access to watch the movie for up to 48 hours.', 
     'image_url' => 'https://filmdemic.com/apps/fb-streaming/wp-main/wp-content/themes/fd-fb-stream-wpf-child/library/images/titles/slidersize/im_not_jesus_mommy.jpg', 
     'product_url' => 'http://filmdemic.com/apps/fb-streaming/film-1/', 
     'price' => '20', 
     'data' => 'film_id=1&wp_user_id=4&view_length=48', 
    ), 
), 
    'status' => 'placed', 
) 
+0

就是這樣。你釘在頭上。我用查找更新了sql數據庫並替換了產品url來改變它們,不知道序列化格式如何工作,從而產生了字符串長度的差異。謝謝! – chuuke 2012-02-01 19:24:07

+0

非常感謝你的想法! unserialize之前的反鋸齒幫助。 – Panoptik 2015-03-27 13:54:28

+0

我很驚訝地發現一個逃逸的角色可能會炸燬序列化/反序列化的明顯僞對稱特性。我們是2016年,反序列化從2000年推出的PHP4開始(!)此外,沉默失敗只是一個/ var_dump地獄的祕訣,我只是通過調試某人的方式發現了困難的方式。 – 2016-07-11 04:51:13