برگزیده های پرشین تولز

UTF-8 Dirify bug and patch

mAmluX

Registered User
تاریخ عضویت
18 می 2005
نوشته‌ها
343
لایک‌ها
0
محل سکونت
Milky Way
جريان اين ديگه چيه ؟ :blink:
http://www.sixapart.com/movabletype/news/2005/06/utf-8_dirify_bug_and_patc.html
-----------------------------------------------------------------------

کد:
Today we are releasing a patch to fix an issue for customers running Movable Type versions 3.16 or 3.17 and using UTF-8 character encoding on their weblogs. Specifically, a bug introduced in Movable Type 3.16 causes the dirify routine to preserve dashes in transformed text where, historically, it has suppressed them. This could be problematic because the dirify routine is used to create all URLs in Movable Type.

While default Movable Type installations are not adversely affected by this bug, there are certain common or legacy customizations (which will be detailed below) that could cause problems. For that reason, if you are using UTF-8 and MT 3.16 or 3.17, we suggest that you download and install the patch just to be safe. The steps are as follows:

   1. Download the patch plugin (1K): tar/gzip (good for Unix), zip (good for Windows)
   2. Uncompress the file as you would Movable Type (e.g. double click it or use a decompression program like Winzip or Stuffit)
   3. Upload the uncompressed file (named patch-20050616-utf8dirify-nodash.pl) to the 'plugins' folder of your main Movable Type application directory.
   4. Rebuild any templates or archives that published statically

More details on the bug and the patch can be found below. We apologize for any inconvenience that this may have caused and thank those of you who brought the issue to light.
Questions and Answers

Q: How does the plugin work?

A: Once installed, the plugin overrides the faulty MT::Util::utf8_dirify() method with its own.

Q: Do I have to uninstall the plugin when I upgrade?

A: Although you're certainly welcome to, it's not required. The plugin will only execute if the Movable Type version is either 3.16 and 3.17. For all other versions (past or future) the plugin will just sit harmlessly in your plugins folder.

Q: How do I know if I'm using UTF-8?

A: The most reliable way to find out if you're using UTF-8 is to look in your mt.cfg file and look for a line that looks like this:

  PublishCharset utf-8

If PublishCharset is set to anything other than 'utf-8', you are not using UTF-8 character encoding and hence are not affected by this bug.

Q: What situations outside of the default configuration might put one at risk for being affected by this bug?

If you are using UTF-8 encoding there are a number of situations where you could be affected, most all of them related to the dirifcation of data to form URLs.

The most common of those would be the following:

    * You have enabled category archives and have one or more categories whose labels contain dashes
    * You publish individual archives and have customized the individual archive map's Archive Filename Template (found on Weblog config » Archive Files and the first row in this screenshot) to use <MTEntryTitle dirify="1"$> or a similar derivative instead MTEntryBasename

In both of these scenarios, Movable Type 3.16 and 3.17 would preserve the dash in the output path/filename, potentially breaking past incoming links to the URLs without the dashes.

Q: Can you show me an example of this issue?

A: In Movable Type 3.15 and previous versions, the phrase 'e-commerce and payment systems' would be dirified to 'ecommerce_and_payment_systems'. In v3.16 and v3.17, the result would be 'e-commerce_and_payment_systems'.

If this were a category name, the URL to that category's archive will have changed due to this bug which could break incoming links.

Q: My entry titles sometimes contain dashes. Why isn't my default-configured individual entry filename affected?

When you save an entry for the first time (regardless of status), Movable Type constucts something called a "base name" and stores it in the database. The base name is based on a trimmed down and dirified entry title and is used as the base file name for the individual entry archive. This ensures, among other things, that if you alter the entry title after publishing, your URL won't change unexpectedly.

Because the stored basename is used and not calculated every time your entries are republished, it doesn't matter which dirify function you used to create it. URLs for entries created under 3.15 did not contain dashes and still don't. URLs for entries created under v3.16 and 3.17 (without the patch) may contain dashes and will continue to even when the patch is installed.

The problem mainly exists for those customers who customized their Individual Archive Filename template before the base name functionality was introduced in MT 3. It was common, in those days, to use something like the following for the Archive Filename Template:

<$MTEntryDate format="%Y/%m"$>/<$MTEntryTitle dirify="1"$>

In this case, the dirify attribute on the entry title would be recalculated each time a page was compiled and hence would be affected by this bug
 

Azemati

کاربر فعال
کاربر قدیمی پرشین تولز
تاریخ عضویت
18 فوریه 2003
نوشته‌ها
3,366
لایک‌ها
4
محل سکونت
wp-config.php

Mashaheer

مدیر بازنشسته
کاربر فعال
تاریخ عضویت
5 می 2003
نوشته‌ها
1,992
لایک‌ها
17
سن
43
محل سکونت
UAE
همانطوری که امیر خان هم گفتند این باگی بوده که در ورژن قبلی ام تی (3.16) بوده و در ورژن جدید درستش کردند.

دوست عزیز شرمنده که من در پستتون دستکاری کردم. من برای اینکه راحتر خونده بشه اون رو توی کد گذاشتم...
 

mAmluX

Registered User
تاریخ عضویت
18 می 2005
نوشته‌ها
343
لایک‌ها
0
محل سکونت
Milky Way
خواهش ميکنم مشاهير جان شما سرور مائين :)
 
بالا