views:

81

answers:

1

I'm getting an unterminated string literal error in Firebug:

Unterminated string literal
$(".search_info").html("<div id=\'sear...arm_bg.png?1279054090\" style=\"displ\n

This error is being rendered from clicking on a Sort By that toggles 'Most Recent'

I have narrowed it down to the 'about_us' text. By removing certain parts of the text, I can get it to work. But it's not because of certain words or characters. It's just how the end result is parsed on the search results (and I'm guessing their alignment).

It gets trickier. I can't reproduce the error on my local machine. It only errors on the server.

The Rails call:

%li
  = image_tag('sortIcon-recent.png')
  = search_sort 'Most Recent', 'published_at', 'desc'

Search Sort Helper

def search_sort(name, sort_by, order = 'asc')
if params[:order_by] && params[:order_by] == sort_by
  link_to(name, url_for(:overwrite_params => { :order_by => sort_by, :direction => order, :page => nil }), :class => 'selected live')
  else
  link_to(name, url_for(:overwrite_params => { :order_by => sort_by, :direction => order, :page => nil }), :class => 'live')
  end
end

The Javascript call:

== $("#search_sort").html("#{ escape_javascript(render :partial => 'search_sort') }");

Further notes: 1. The text is placed in CKeditor. 2. It's parsed using Ruby's truncate command ( which has a history of destroying WYSIWYG text by adding hidden characters into it )

As far as an answer goes, does anyone know how I can further debug this, or what to do from here?

Here is the full extracted GET request ( I have read these several times over and can not find an unterminated string literal ) :

$(".search_info").html("<div id=\'searchWindow\'>\n<div id=\'searchContent\'>\n<div class=\'search_result\'>\n<img alt=\"Farm_bg\" class=\"search_image_banner\" height=\"204\" src=\"/system/search_images/993/cropped/farm_bg.png?1279054090\" style=\"display: none;\" width=\"285\" />\n<div class=\'grid_8 alpha\'>\n<div class=\'left\'>\n<img alt=\"Farm_bg\" src=\"/system/search_images/993/thumb/farm_bg.png?1279054090\" />\n<\/div>\n<div class=\'grid_3 omega\'>\n<h1><a href=\"/organizations/coviellobrothers\">Coviello Brothers <\/a><\/h1>\n<div class=\'clear\'><\/div>\n<h3>Madison<\/h3>\n<div class=\'clear\'><\/div>\n<div class=\'class7\'>\nJust This And Much More\n<\/div>\n<div class=\'clear\'><\/div>\n<\/div>\n<div class=\'grid_4 omega alpha\'>\n<div class=\'left\' style=\'margin-right: 12px; width: 40px\'>\n&nbsp;\n<\/div>\n<div class=\'left\' style=\'margin-right: 12px; width: 40px\'>\n<a href=\"/organizations/993/deals/view\"><img alt=\"Hq-card-icon\" src=\"/images/hq-card-icon.png?1279112378\" /><\/a>\n<\/div>\n<div class=\'left\' style=\'margin-right: 12px; width: 40px\'>\n&nbsp;\n<\/div>\n<div class=\'clear\'><\/div>\n<\/div>\n<div class=\'grid_4 omega alpha\' style=\'height: 25px; overflow: hidden;\'>\n<p>\n    Coviello Brothers serving Landscape Customers For Over 30 Years\n   \n  \n  located In Madison, C...<\/p>\n<\/div>\n<div class=\'clear\'><\/div>\n<\/div>\n<div class=\'clear\'><\/div>\n<\/div>\n<div class=\'clear\'><\/div>\n<\/div>\n<\/div>\n<div class=\'clear\'><\/div>\n<br />\n<div class=\'align_right\'><\/div>\n<div class=\'clear\'><\/div>\n");
$("#search_sort").html("<div class=\'class7\'>\nSort By:\n<\/div>\n<div class=\'clear\'><\/div>\n<div id=\'sort\' style=\"background: url(\'/images/sort-box-large.png\') no-repeat; padding: 15px 10px\">\n<ul>\n<li>\n<img alt=\"Sorticon-24hr\" src=\"/images/sortIcon-24hr.png?1279112378\" />\n<a href=\"/organizations/search?_=1279118265076&amp;commit=go&amp;direction=desc&amp;order_by=contactable&amp;q=coviello+brothers\" class=\"live\">24hr Contact<\/a>\n<\/li>\n<li>\n<img alt=\"Sorticon-card\" src=\"/images/sortIcon-card.png?1279112378\" />\n<a href=\"/organizations/search?_=1279118265076&amp;commit=go&amp;direction=desc&amp;order_by=best_deal_score&amp;q=coviello+brothers\" class=\"live\">HQcard Promotion<\/a>\n<\/li>\n<li>\n<img alt=\"Sorticon-video\" src=\"/images/sortIcon-video.png?1279112378\" />\n<a href=\"/organizations/search?_=1279118265076&amp;commit=go&amp;direction=desc&amp;order_by=number_of_videos&amp;q=coviello+brothers\" class=\"live\">Video<\/a>\n<\/li>\n<li>\n<img alt=\"Sorticon-trust\" src=\"/images/sortIcon-trust.png?1279112378\" />\n<a href=\"/organizations/search?_=1279118265076&amp;commit=go&amp;direction=desc&amp;order_by=rating&amp;q=coviello+brothers\" class=\"live\">Trust Ranking<\/a>\n<\/li>\n<li>\n<img alt=\"Sorticon-recent\" src=\"/images/sortIcon-recent.png?1279112378\" />\n<a href=\"/organizations/search?_=1279118265076&amp;commit=go&amp;direction=desc&amp;order_by=published_at&amp;q=coviello+brothers\" class=\"selected live\">Most Recent<\/a>\n<\/li>\n<li>\n<\/li>\n<\/ul>\n<\/div>\n<div class=\'clear\'><\/div>\n");
$("#search_pagination").html("");
$("#search_total h6").html("1 Result Returned!");
$("#middle_search_banner").html("<img alt=\"Farm_bg\" height=\"204\" id=\"search_image_banner\" src=\"/system/search_images/993/cropped/farm_bg.png?1279054090\" width=\"285\" />\n");

Here is the text that breaks it (this was pasted as plain text in CKeditor ). Also, as a reminder, I tried removing the ":" and other characters, but it still produced the same error:

Coviello Brothers 

Serving Landscape Customers for over 30 years. Located in Madison, Coviello Brothers is a full service design and build landscape business that is family owned and operated since 1973. We have a licensed landscape architect on staff to assist you with your design ideas.

We are licensed for irrigation installation, pesticide application, and certified for stone wall construction. We offer a full range of landscaping services including:

+4  A: 

you have an unterminated string literal:

$(".search_info").html("<div id=\'sear...arm_bg.png?1279054090\" style=\"displ\n

id opens with ' and closes with "

Matt Ellen
You have eyes like a hawk
Trip
Unfortunately I also have talons, so typing is quite hard.
Matt Ellen
Though that's what the error says, if it included everything that that "..." meant, then we would have seen this.. $(".search_info").html("<div id=\'searchWindow\'>\n<div id=\'searchContent\'>\n<div class=\'search_result\'>\n<img alt=\"Farm_bg\" class=\"search_image_banner\" height=\"204\" src=\"/system/search_images/993/cropped/farm_bg.png?1279054090\" . Which is properly escaped.
Trip
Here's another example of the error, $(".search_info").html("<div id=\'sear.../993/cropped/Landscape_Design-1001.pn\n
Trip
I see. I'll have another look.
Matt Ellen