diff --git a/lib/store_search/parsers/play_store_parser.rb b/lib/store_search/parsers/play_store_parser.rb
index cad9e44..3974b51 100644
--- a/lib/store_search/parsers/play_store_parser.rb
+++ b/lib/store_search/parsers/play_store_parser.rb
@@ -11,7 +11,9 @@ def description
description = params.description.gsub(/<\s*br\s*\/?\s*>/, "\n") # replace
with \n
description = description.gsub(/(?=<\s*p\s*>)/, "\n") # add \n before
description = description.gsub(/(display\s*:\s*none.*?>)(.*)/m, '\1') # remove text after style="display:none">
- HTMLEntities.new.decode Sanitize.fragment(description, Sanitize::Config::RESTRICTED).strip
+ HTMLEntities.new.decode Sanitize.fragment(description, Sanitize::Config.merge(Sanitize::Config::RESTRICTED,
+ parser_options: { max_errors: -1, max_tree_depth: -1 }
+ )).strip
end
def publisher
diff --git a/spec/lib/parsers/play_store_parser_spec.rb b/spec/lib/parsers/play_store_parser_spec.rb
index 7974060..8946c55 100644
--- a/spec/lib/parsers/play_store_parser_spec.rb
+++ b/spec/lib/parsers/play_store_parser_spec.rb
@@ -103,4 +103,54 @@ def parse_min_os_version(version)
end
end
end
+
+ describe '#description' do
+ def parse_description(description)
+ StoreSearch::PlayStoreParser.new(OpenStruct.new(description: description)).description
+ end
+
+ context 'when description is usual' do
+ it 'returns parsed and decoded description' do
+ description = '
„★ some
more
description
and
other
stuff ★&ldqu'\
+ 'o; hiddentext '
+ expect(parse_description(description)).to eq("„★ some\nmore \ndescription\n and other\nstuff ★“ hidden")
+ end
+ end
+
+ context 'when description exceeds default tree depth limit' do
+ it 'returns parsed and decoded description' do
+ description = '
Backgammon is one of the world’s most popular board g'\
+ 'ames, brought to you by the makers of Nonogram.com and Sudoku.com puzzles. Install Backgammon for free now, t'\
+ 'rain your brain and have fun!\n\nBackgammon board game (also known as Nardi or Tawla ) is one of the oldest l'\
+ 'ogic games in existence, alongside Chess and Go. People from all over the world have been playing backgammon '\
+ 'classic for more than 5000 years to socialize with family and friends and keep their brains active.\n\nHow to'\
+ ' play the Backgammon classic game\n\n- Classic Backgammon is a logic puzzle for two, played on a board of 24 '\
+ 'triangles. These triangles are called points.\n- Each player sits on the opposite sides of the board with 15 '\
+ 'checkers, black or white.\n- To start the game, players take turns and roll the dice. That’s why free B'\
+ 'ackgammon is often called a dice game.\n- Players move pieces based on the numbers rolled. For example, if yo'\
+ 'u roll 2 and 5, you can move one piece 2 points and another one 5 points. Alternatively, you can move one pie'\
+ 'ce 7 points.\n- Once all of a player’s pieces are on the opponent’s “home”, that play'\
+ 'er may begin removing pieces off of the board.\n- A player wins once all of their pieces are removed from the'\
+ ' board\n\nA few more things to know\n\n- Rolling two of the same number allows you to move 4 times. For examp'\
+ 'le, for a roll of 4 and 4, you can move a total of 16 points, although each piece must move 4 points at a tim'\
+ 'e.\n- You cannot move a piece to a point that is occupied by 2 or more of your opponent’s pieces\n- If '\
+ 'you move a piece to a point with only 1 of your opponent’s pieces on it, the rival’s piece is rem'\
+ 'oved from the board and placed on the middle partition.\n\nBackgammon Free Features\n\n- Enjoy a fair dice ro'\
+ 'll, which only the best backgammon games can boast.\n- Undo a move if you made it accidentally or came up wit'\
+ 'h a better one right after\n- Your possible moves are highlighted to help you make an easier decision\n- A si'\
+ 'mple and intuitive design to better focus on the game\n- Start with easy opponents and face more difficult on'\
+ 'es as you practice on your way to becoming the Backgammon king.\n\nInteresting facts about Backgammon\n\n- An'\
+ 'cient Romans, Greeks, and Egyptians all loved playing Backgammon (known as tawla or narde). \n- Backgammon is'\
+ ' a classic game of luck and strategy. While any dice game is pretty much pure luck, there’s also an inf'\
+ 'inite number of strategies that even include predicting your opponent’s moves.\n- One thing logic games'\
+ ' have in common – they keep your brain sharp. It may not be difficult to learn the basics of Backgammon'\
+ ', but you’ll need an entire lifetime to become a true lord of the board.\n\nBackgammon Classic is one o'\
+ 'f the most popular free board games ever. Download it now and challenge yourself!
'
+
+ expect(parse_description(description)).to start_with('Backgammon is one of the world’s most popular')
+ expect(parse_description(description)).to end_with('Download it now and challenge yourself!')
+ end
+ end
+ end
end