2011-08-18 7 views
0

當IAM試圖EVAL:如何逃生」中的eval它拋出錯誤:預期標識符

<span style=\"color: #ff0000;\"> 

它拋出錯誤時,意想不到的標識如何逃生呢

我得到的結果?服務器aaaas如下:,在EXT JS(JS框架)閱讀器無法讀取它。

{ 
    "items": [{ 
     "id": "671", 
     "post_title": "Seche Vite Dry Fast Top Coat", 
     "post_content": "<span style=\"color: #ff0000;\"><strong>Roy Recommends:<\/strong>\u00c2\u00a0 Edith, our in-house nail expert, swears by this product.\u00c2\u00a0 No manicure or pedicure is complete without adding this top coat as the finishing touch.<\/span>\r\n\r\nSeche Vite\u00e2\u201e\u00a2 dry fast top coat is widely acknowledged as the world\'s finest top coat.\u00c2\u00a0 Specially formulated to penetrate through nail lacquer to the base coat forming a single solid coating over the nail plate for a much more durable finish. Guaranteed not to yellow while leaving nails silky, stronger and resistant to chipping and peeling.\r\n\r\n&nbsp;", 
     "post_excerpt": "", 
     "post_status": "publish", 
     "post_parent": "0", 
     "parent_sort_id": "671", 
     "prod_meta_data_key": "_wpsc_product_metadata", 
     "category": "Roy Recommends,Nail Care", 
     "_wpsc_price": "10", 
     "_wpsc_special_price": "0", 
     "_wpsc_sku": "", 
     "_wpsc_stock": "4", 
     "unpublish_when_none_left": "1", 
     "weight": 8.5, 
     "weight_unit": "ounce", 
     "height": "0", 
     "height_unit": "in", 
     "width": "0  ", 
     "width_unit": "in", 
     "length": "0", 
     "length_unit": "in", 
     "local": "0", 
     "international": "0", 
     "no_shipping": "0" 
    }], 
    "totalCount": "1" 
} 
+1

你爲什麼試圖在javascript中評估HTML? – JaredPar

+0

其獲得json編碼結果的一部分 –

+0

您需要向我們提供更多信息。根本不需要評估HTML。 – mplungjan

回答

1

嘗試使用單引號代替雙引號<span color='blue'>...</span>

或者直接將HTML格式化,而不是直接格式化,只需發送數據並處理格式化客戶端,即可知道數據的標識符,這樣您就可以將其單獨格式化。

+0

What Epoch建議不發送標記。 – mplungjan

+0

我無法控制HTML作爲它的HTML編輯器,用戶將格式化他想要的方式 –

+0

您將不得不使用模板樣式或類似的東西那麼,XSS注入等如何。直接從用戶讀取HTML不是最好的選擇 – epoch