Jump to content

[SHARE] HTML catch validation and decreased heap


Recommended Posts

Simple share reduce the heap of the html cache(less memory usage)and adds html validation(find incorrect tags in html files which usually ingame end up in a html is too long text).

 

Patch for gracia epilogue L2J but simple to adapt to any chronicle(L2J only L2JFree have validation alredy since ages)

 

### Eclipse Workspace Patch 1.0
#P L2_GameServer
Index: java/com/l2jserver/gameserver/cache/HtmCache.java
===================================================================
--- java/com/l2jserver/gameserver/cache/HtmCache.java	(revision 4299)
+++ java/com/l2jserver/gameserver/cache/HtmCache.java	(working copy)
@@ -18,15 +18,16 @@
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.l2jserver.Config;
import com.l2jserver.gameserver.util.Util;

-import javolution.util.FastMap;
-
/**
  * @author Layane
  *
@@ -39,6 +40,16 @@

	private int _loadedFiles;
	private long _bytesBuffLen;
+	
+	private static final String[] VALID_TAGS = { "volumn", "unknown", "ul", "u", "tt", "tr", "title", "textcode", "textarea", "td", "table", "sup", "sub", "strike", "spin", "select", "right", "pre", "p", "option", "ol", "multiedit", "li", "left", "input", "img", "i", "html", "h7", "h6", "h5", "h4", "h3", "h2", "h1", "font", "extend", "edit", "comment", "combobox", "center", "button", "br", "br1",
+		"body", "bar", "address", "a", "sel", "list", "var", "fore", "readonl", "rows", "valign", "fixwidth", "bordercolorli", "bordercolorda", "bordercolor", "border", "bgcolor", "background", "align", "valu", "readonly", "multiple", "selected", "typ", "type", "maxlength", "checked", "src", "y", "x", "querydelay", "noscrollbar", "imgsrc", "b", "fg", "size", "face", "color", "deffon",
+		"deffixedfont", "width", "value", "tooltip", "name", "min", "max", "height", "disabled", "align", "msg", "link", "href", "action", "head", "tbody" };
+	private final static HashSet<String> VALID_TAGS_SET = new HashSet<String>(301);
+	static
+	{
+		for (String tag : VALID_TAGS)
+			VALID_TAGS_SET.add(tag);
+	}

	public static HtmCache getInstance()
	{
@@ -47,7 +58,7 @@

	private HtmCache()
	{
-		_cache = new FastMap<Integer, String>();
+		_cache = new HashMap<Integer, String>(16000);
		reload();
	}

@@ -62,6 +73,8 @@
		{
			_log.info("Html cache start...");
			parseDir(f);
+			_log.info("Validation starts...");
+			validate();
			_log.info("Cache[html]: " + String.format("%.3f", getMemoryUsage()) + " megabytes on " + getLoadedFiles() + " files loaded");
		}
		else
@@ -239,6 +252,32 @@

		return false;
	}
+	
+	private void validate()
+	{
+		for (Entry<Integer, String> entry : _cache.entrySet())
+		{
+			final String html = entry.getValue();
+			outer: for (int begin = 0; (begin = html.indexOf("<", begin)) != -1; begin++)
+			{
+				int end;
+				for (end = begin; end < html.length(); end++)
+				{
+					if (html.charAt(end) == '>' || html.charAt(end) == ' ')
+						break;
+					// some special quest-replaced tag
+					if (end == begin + 1 && html.charAt(end) == '?')
+						continue outer;
+				}
+				end++;
+				String tag = html.substring(begin + 1, end - 1).toLowerCase().replaceAll("/", "");
+				if (!VALID_TAGS_SET.contains(tag))
+				{
+					_log.info("Invalid tag used: '" + tag + "' at pos " + (begin + 1) + " " + entry.getKey());
+				}
+			}
+		}
+	}

	@SuppressWarnings("synthetic-access")
	private static class SingletonHolder

Link to comment
Share on other sites

Just an advice for you and not only...

Stop losing your time with someone's else code. You, most developers in here, got a good start but you lost it on the way up because you never tried to do something different and harder. Take chalanges, code something that you consider you're not prepared for. Always work on stuff with one stage higher than the stage you are at.

 

L2j is a business and you can get pretty money out of it but you have to be prepared for anything, not just easy, normal stuff which anyone can do. That makes you a developer, the rest is wannabes.

 

Good luck to you, and not only.

Link to comment
Share on other sites

Just an advice for you and not only...

Stop losing your time with someone's else code. You, most developers in here, got a good start but you lost it on the way up because you never tried to do something different and harder. Take chalanges, code something that you consider you're not prepared for. Always work on stuff with one stage higher than the stage you are at.

 

L2j is a business and you can get pretty money out of it but you have to be prepared for anything, not just easy, normal stuff which anyone can do. That makes you a developer, the rest is wannabes.

 

Good luck to you, and not only.

 

And who said i dont do that? :)

 

I think we can agree in 1 thing hard work never shared in public ;)

Link to comment
Share on other sites

And who said i dont do that? :)

 

I think we can agree in 1 thing hard work never shared in public ;)

 

Another tip for you. You probably noticed I had no shares lately. And I mean NONE!

 

Oh well, I got awared of the fact that L2j, as most online things, became a business. Money are done on the internet now. Most of them!

 

L2J as a business and a market of sell means much. A single mistake can fuck up the whole market. One shared piece of code that shouldn't be shared can get a lot of money lost. That's why I'm not for sharing anymore. You want any code you can think of? You pay for it. You want to make a server and get money out of donations afterall, don't you? That's a business and as any other business out there you have to invest in it.

 

Make me understand the concept of me, as a developer, to code something from MY OWN and share it with every else. Most of the guys in here got no idea I'm learning this for a very, very long time. Most of the guys got no idea that at 13 years old I was coding flooders in Visual Basic for DC++ networks. I lost a lot and I gained a lot. Why should I use MY OWN lost years for someone else? Why should I share the code I MADE with someone else? I worked hard to be able to do it. Now I do it for myself, and selling it, is doing it for myself too. Give me just ONE SINGLE advantage of sharing something that I could get money out of. You cant. You will talk about fame. You get fame by sharing and that's right. Next, what you're going to do with that fame? Just nothing. I get fame and I get paid at the same time, I consider that WAY better.

 

Hope you all got the point Im going for and there will be no flames like "wtf u doing here if u'r not for sharing then?". Im here for the people who know me and Im here to SELL STUFF. Noone can forbid me that.

Link to comment
Share on other sites

Another tip for you. You probably noticed I had no shares lately. And I mean NONE!

 

Oh well, I got awared of the fact that L2j, as most online things, became a business. Money are done on the internet now. Most of them!

 

L2J as a business and a market of sell means much. A single mistake can -beep- up the whole market. One shared piece of code that shouldn't be shared can get a lot of money lost. That's why I'm not for sharing anymore. You want any code you can think of? You pay for it. You want to make a server and get money out of donations afterall, don't you? That's a business and as any other business out there you have to invest in it.

 

Make me understand the concept of me, as a developer, to code something from MY OWN and share it with every else. Most of the guys in here got no idea I'm learning this for a very, very long time. Most of the guys got no idea that at 13 years old I was coding flooders in Visual Basic for DC++ networks. I lost a lot and I gained a lot. Why should I use MY OWN lost years for someone else? Why should I share the code I MADE with someone else? I worked hard to be able to do it. Now I do it for myself, and selling it, is doing it for myself too. Give me just ONE SINGLE advantage of sharing something that I could get money out of. You cant. You will talk about fame. You get fame by sharing and that's right. Next, what you're going to do with that fame? Just nothing. I get fame and I get paid at the same time, I consider that WAY better.

 

Hope you all got the point Im going for and there will be no flames like "wtf u doing here if u'r not for sharing then?". Im here for the people who know me and Im here to SELL STUFF. Noone can forbid me that.

 

you dont need to tell me that because i do the exact same but some hype to keep your name up never comes bad :)

Link to comment
Share on other sites

you dont need to tell me that because i do the exact same but some hype to keep your name up never comes bad :)

 

I used the oportunity to explain this to anyone else, not just to you.

 

Keep up the good work. I hope Ill see you soon saying "Got no time to stay late for the drink guys, got some projects to do for good money".

Link to comment
Share on other sites

I used the oportunity to explain this to anyone else, not just to you.

 

Keep up the good work. I hope Ill see you soon saying "Got no time to stay late for the drink guys, got some projects to do for good money".

We are talking about Intrepid you know...

 

Ty very much for this share mate...

Link to comment
Share on other sites

I used the oportunity to explain this to anyone else, not just to you.

 

Keep up the good work. I hope Ill see you soon saying "Got no time to stay late for the drink guys, got some projects to do for good money".

 

friends  > all so thats not going to happen but thank you i make fine amount of money with l2j :)

Link to comment
Share on other sites

The thing you forget Vago, it's some ppl makes L2J for free, and you use it to make money on it.

 

Without this teamwork, I don't think you would dev or make money. Just think a lil.

 

Anyway, ty for the -FREE- share. And death to this capitalist conception of coding (and no I'm not a Linux fan).

 

BTW, showing some codes sometimes just show he got talent, just show his programmer skill and make him publicity. You missed a marketing lesson...

 

I don't defend Intrepid, and I have nothing with you Vago. :).

 

----

 

Have you taken the idea from your old anti-L2W commit ? It looks the same :D.

Link to comment
Share on other sites

The thing you forget Vago, it's some ppl makes L2J for free, and you use it to make money on it.

 

Without this teamwork, I don't think you would dev or make money. Just think a lil.

 

Anyway, ty for the -FREE- share. And death to this capitalist conception of coding (and no I'm not a Linux fan).

 

BTW, showing some codes sometimes just show he got talent, just show his programmer skill and make him publicity. You missed a marketing lesson...

 

I don't defend Intrepid, and I have nothing with you Vago. :).

 

----

 

Have you taken the idea from your old anti-L2W commit ? It looks the same :D.

 

Actually that was done way before my anti l2w try :D

Thats made back in l2emu nearly 9months old code :D

Link to comment
Share on other sites

The thing you forget Vago, it's some ppl makes L2J for free, and you use it to make money on it.

 

Without this teamwork, I don't think you would dev or make money. Just think a lil.

 

Anyway, ty for the -FREE- share. And death to this capitalist conception of coding (and no I'm not a Linux fan).

 

BTW, showing some codes sometimes just show he got talent, just show his programmer skill and make him publicity. You missed a marketing lesson...

 

I don't defend Intrepid, and I have nothing with you Vago. :).

 

----

 

Have you taken the idea from your old anti-L2W commit ? It looks the same :D.

 

They could have made lots of money with a non-shared l2j but that's their work and they do whatever they want with it. Im just saying I wont share my considerable work ever again. :)

Link to comment
Share on other sites

They could have made lots of money with a non-shared l2j but that's their work and they do whatever they want with it. Im just saying I wont share my considerable work ever again. :)

 

And you are right with that but as i said before some "hipe" never hurt. :)

Link to comment
Share on other sites

Oh well, I got awared of the fact that L2j, as most online things, became a business. Money are done on the internet now. Most of them!

client modding is awarded the same way...

 

If you do something for free you end up with 99% of the people using it do nothing in return

 

Do realise that thanks to those who did spend their time sharing/making l2j allowed you to now make money from it; the same way I'm still infinitely thankful to those that shared the first guides/tools how to edit L2 client.

 

Thanks for sharing Interpid, it seems helpful

Link to comment
Share on other sites

Actually that was done way before my anti l2w try :D

Thats made back in l2emu nearly 9months old code :D

 

Buhaha.

 

Btw, you should make the message more friendly, cause actually you know you got error in "x" files, but which exactly are them...

 

Or show only useful infos, like bad tags and the total numbers of files, cause if you got 150 bad tags, that shows 150 errors ? Not rly exploitable in a GS log:P.

 

And the big numbers I don't get the use :D. About the pos, it's the file which have been loaded ? So you know it's the 1849th loaded file which bugs ? Not rly exploitable ^^.

 

(Ok with notepad ++ you search for the bad tag in the folder, but still :p.)

 

Works fine on my Archid custom, you have to disable the Lazy cache.

 

plopa.jpg

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


  • Posts

    • DISCORD :   utchiha_market   telegram    https://t.me/utchiha_market   SELLIX STORE :   https://utchiha-market.mysellix.io/   Join the server for more products :   https://discord.gg/hoodservices
    • When it comes to encrypting passwords, using a strong hashing algorithm like SHA-256 or bcrypt is recommended. These algorithms help ensure that passwords are securely stored and protected from being easily decrypted.
    • ***CLExt L2OFF Extender Premium Account Save - Auto Login***   We would like to sell account panel for save accounts for server owners or self player.  You can login and save your id and pass accounts or delete it etc.       Price: 100 euro.   ***CLExt L2OFF Extender Premium Auto-Farm Macro System*** We would like to sell Auto-Farm Macro System for server owners or self player.  You can add your potions and your macro to farm your character with your standars.       Price: 100 euro.   If you like to order send me DM or skype zoumhs999.
    • Diablo III, the action-packed hack-and-slash RPG developed by Blizzard Entertainment, has captivated gamers worldwide since its release in 2012. Now, imagine a world where Diablo III's source code is opened up to the community, inviting developers and enthusiasts alike to enhance and refine this beloved game. This topic delves into the possibilities, challenges, and community desires surrounding the idea of Diablo III as an open-source project.   Key Points: 1. Defining Diablo III: Diablo III is an action role-playing game set in the dark fantasy world of Sanctuary. Players traverse through randomized dungeons, battling hordes of demons and collecting loot to strengthen their characters. With its compelling storyline, addictive gameplay mechanics, and rich lore, Diablo III has amassed a dedicated fanbase over the years.   2. Open Source Potential: Opening up the source code of Diablo III could unlock a wealth of opportunities for the game's future. Community developers could introduce new features, enhance existing gameplay elements, and address long-standing issues. The modding community, known for its creativity and innovation, could breathe new life into the game by creating custom content, game modes, and user interface improvements. 3. Community Interest: The question arises - would the gaming community welcome the idea of Diablo III becoming open source? Many players are eager to see the game evolve beyond its current state, with enhancements such as improved balance, expanded end-game content, and enhanced multiplayer features. By involving the community in the development process, Diablo III could foster a stronger sense of ownership and collaboration among its players. 4. Challenges and Considerations: While the concept of Diablo III as an open source is enticing, it also presents several challenges. Ensuring the integrity of the game's balance and preventing cheating would be paramount concerns. Additionally, coordinating development efforts and maintaining a cohesive vision for the game could prove challenging in a community-driven environment. However, with proper oversight and collaboration, these obstacles can be overcome. 5. Is Diablo III an MMORPG? Diablo III is often categorized as an action RPG rather than a traditional MMORPG (massively multiplayer online role-playing game). While it does feature online multiplayer elements, including cooperative play and player-versus-player combat, it lacks the persistent open world typically associated with MMORPGs. Instead, Diablo III focuses on instanced dungeons and smaller-scale multiplayer interactions. The Benefits of Improvement: Improving Diablo III through open-source development could revitalize the game, attracting new players and re-engaging existing fans. By embracing community-driven innovation, Diablo III could remain relevant and enjoyable for years to come. Additionally, fostering an active modding community could extend the game's longevity and create new opportunities for player expression and creativity.   Source code  
  • Topics

×
×
  • Create New...