﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	mlocked
11536	Fix hard-coded string lengths	Jim Stichnoth	Jim Stichnoth	"The code base has many fragile string comparisons like:

{{{
if (me->Message().left(23) == ""MASTER_UPDATE_PROG_INFO"")
}}}

The attached patch applies the following transformations, where N is a numeric constant and c is a string:

{{{
(s.left(N) == c)  ==>   (s.startsWith(c))
(s.left(N) != c)  ==>   (!s.startsWith(c))
(s.right(N) == c)  ==>  (s.endsWith(c))
(s.right(N) != c)  ==>  (!s.endsWith(c))
(s.left(N).toLower() == c)  ==>   (s.startsWith(c, Qt::CaseInsensitive))
(s.left(N).toLower() != c)  ==>   (!s.startsWith(c, Qt::CaseInsensitive))
(s.right(N).toLower() == c)  ==>  (s.startsWith(c, Qt::CaseInsensitive))
(s.right(N).toLower() != c)  ==>  (!s.startsWith(c, Qt::CaseInsensitive))
}}}

Through manual inspection and lots of counting on my fingers, I found two errors in the code.  In CC608Decoder::GetXDS():

{{{
else if (key.left(11) == ""has_future_rating_"")
}}}

and in HttpConfig::ProcessRequest():

{{{
if (request->m_sBaseUrl.right(7) == ""config""
}}}

The latter was already noted in a FIXME comment."	Developer Task	closed	minor	0.27	MythTV - General	Master Head	medium	fixed			0
